Open hyitclj opened 8 years ago
Just reading the source code and it appears to cancel all existing alarms whenever window.wakeuptimer.wakeup() is called. I'm guessing you pass and empty 'alarms' array in the call and it will cancel all alarms. A pretty terrible way to 'cancel an alarm' imo, but I guess its better than nothing :\
Hi @se1exin, I'm having trouble removing the alarms the way you described (by passing an empty array). Is there another way?
Hi @isvaljek, its been nearly a year since I've used this plugin so I may be wrong on this..
Looking at the Android source for WakeupPlugin.java, if you call snooze the plugin will eventually call cancelAlarms
- which will cancel all alarms. Directly beneath the cancel the plugin then re-schedules the alarms - BUT if you pass it an empty array, nothing gets rescheduled, effectively just cancelling all alarms. Note you MUST pass the snooze
function an alarms array, or it will throw an error and not cancel the alarms.
So I would do something like this:
window.wakeuptimer.snooze(
successCallback,
errorCallback,
{
alarms : []
}
);
Good luck!
Thanks @se1exin , but it seems that the cancelAlarms leaves behind a couple of alarms. I'm not sure but if I clear the alarms the way you describe, and then set a single 7-day alarm, I always end up getting one or two previously cleared dates (ghosts) when I run adb shell dumpsys alarm. It seems that clearing daylist type of alarms always leaves last alarm day set.
@isvaljek I get ya. Sorry but it's been too long so I'm of no more help help here :( Best I can suggest is fork the repo and add the functionality you need
How to cancel the alarm clock