Skip to content

Commit

Permalink
Android: checking for exact alarms permission before scheduling notif…
Browse files Browse the repository at this point in the history
…ications (#659)
  • Loading branch information
zdmitrynsk authored Mar 17, 2024
1 parent dce7457 commit 7975411
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,14 @@ private void postSystemNotification(NotificationSettings settings) {
android.app.AlarmManager alarmManager;
String serviceName = android.content.Context.ALARM_SERVICE;
alarmManager = (android.app.AlarmManager)context.getSystemService(serviceName);
if (android.os.Build.VERSION.SDK_INT >= 23) {

if (android.os.Build.VERSION.SDK_INT >= 33 && !alarmManager.canScheduleExactAlarms()) {
alarmManager.set(
android.app.AlarmManager.RTC_WAKEUP,
scheduledSettings.getEndTime().getTime(),
pendingIntent);
}
else if (android.os.Build.VERSION.SDK_INT >= 23) {
NotificationServices.ApiLevel23.alarmManagerSetExactAndAllowWhileIdle(
alarmManager,
android.app.AlarmManager.RTC_WAKEUP,
Expand Down

0 comments on commit 7975411

Please sign in to comment.