Skip to content

Commit

Permalink
Added alarm call that will work in doze mode
Browse files Browse the repository at this point in the history
Merge in improvement from wnyc#32 by @DavidBriglio
  • Loading branch information
alexhisen authored Aug 28, 2019
1 parent a61abc3 commit 694779e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/android/WakeupPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ protected static void setNotification(Context context, String type, Calendar ala
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Log.d(LOG_TAG,"setting alarm at " + sdf.format(alarmDate.getTime()) + "; id " + id);

if (Build.VERSION.SDK_INT>=19) {
if (Build.VERSION.SDK_INT >= 23) {
// This method will be triggered even with doze mode activated (limited to once per 9 minutes per app)
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, alarmDate.getTimeInMillis(), sender);
} else if (Build.VERSION.SDK_INT>=19) {
alarmManager.setExact(AlarmManager.RTC_WAKEUP, alarmDate.getTimeInMillis(), sender);
} else {
alarmManager.set(AlarmManager.RTC_WAKEUP, alarmDate.getTimeInMillis(), sender);
Expand Down

0 comments on commit 694779e

Please sign in to comment.