$rootScope.$on('$cordovaLocalNotification:cancelall', function(event, state) {}) to check if it gets fired or not.
Secondly, i read somewhere that cancelallnotifications have been deprecated in IOS 10. Maybe thats why its not working( Not Sure ). I don’t see it in the cordova repo wiki also :
If you don’t find the solution, you can have a workaround by getting all IDs and then canceling them in a loop.
$ionicPlatform.ready(function() {
cordova.plugins.notification.local.schedule({
id : 1,
title : 'I will bother you every minute',
text : '.. until you cancel all notifications',
sound : null,
autoClear : false,
at : _10SecondsFromNow
});
cordova.plugins.notification.local.getScheduledIds(
function (scheduledIds) {
for (var i = 0; scheduledIds.length > i; i++) {
window.plugin.notification.local.cancel(localIDlist[i]);
}
}
)
})
But without success, I changed the plugin to this one because it seems more updated:
I did it this way too:
window.plugin.notification.local.getScheduledIDs.getScheduledIds(
function (scheduledIds) {
for (var i = 0; scheduledIds.length > i; i++) {
window.plugin.notification.local.cancel(localIDlist[i]);
}
}
)
Does not have support for the version of android 6?
Thanks
I think I’ll look for another way, because canceling notifications does not seem to be very good. The onesignal for example did not even implement this method
The user enters a parking lot, when he clicks on pay I would schedule a notification for when missing a few minutes to the end of the contracted time I display a notification to renew. But the condition for this is if it is at least 1km from the parking lot. If it is not in this range, I would cancel the notification.
Nice use case.
Have you looked into OneSignal’s clearOneSignalNotifications() and cancelNotification() methods, which can be used if you need to programmatically dismiss notifications so they are not restored.
Sounds like you got this solved a different way, but I thought I’d mention the original problem may well have been that you deleted before the notification was registered.
It takes time to schedule a notification, hence it returning a promise. Rather than waiting for it to come back successfully registerd, you call cancelAll immediately.
At the beginning of all my idea was to do with the onesignal, so much that I already had the code ready. But as in the documentation the cancel function was like “soon” I tried $cordovaLocalNotification as an alternative.
But the idea was always to use the onesignal, with the help of @thesourav I was able to execute the main plan.
I think you’re right about promise, as I just remembered that in one of the tests the alert of the cancel method came first.