hi I am using phonegap local notification plugin in my android project.
notification are working great.
i can delete a notification with ID
but in my app i have to delete all notification option, for which this plugin gives a method to cancelAll notification.
which is:-
plugins.localNotification.cancelAll();
but this is not working.
i am using this plugin from here
https://github.com/phonegap/phonegap-plugins/tree/master/Android/LocalNotification
any help will be appreciated.
I think this might be the answer to this one. As it says in the description of the
cancelAllNotifications()method (LocalNotification.java line 124):However, take a look at the code where the
cancelAllNotifications()method is called (line 59):Here’s what
unpersistAlarmAll()looks like (line 181):What’s happening is that the alarmIds are being cleared from sharedPreferences before
cancelAllNotifications()is called, effectively leaving no alarms to be canceled.I’m not sure where the best place to move the call to
unpersistAlarmAll()is, and I’d be happy to get some suggestions. In the meantime I have moved it to withincancelAllNotifications(), after the result returned fromalarm.cancelAll(alarmSettings)is tested (line 133), like so:So far this seems to be working fine. Perhaps another way to do this would be to scrap the whole
unpersistAlarmAll()method and instead callunpersistAlarm(String alarmId)(line 168) after each individual alarm is successfully canceled.