Reputation: 1674
I have been trying to get local notifications working on an Ionic 1 iOS app. I've installed the local notification plugin, and I can schedule notifications, but the callbacks don't seem to fire.
I can schedule a notification and it displays properly when the app is in the background:
cordova.plugins.notification.local.schedule({
text: "Delayed Notification",
at: new Date(new Date().getTime() + 5*1000)
});
But events never fire:
cordova.plugins.notification.local.on("click", function(notification) {
alert("clicked: " + notification.id);
});
Upvotes: 0
Views: 686
Reputation: 2424
I had similar issues.
Not sure if this is a bad idea but I had to put my trigger callback in appmodule and then it worked.
//Trigger to monitor notifications in case they need to be cleared
localNotifications.on("trigger", (notification, state) => {
console.log("Triggering notification (App Module)",notification);
});
Upvotes: 0
Reputation: 1
cordova.plugins.notification.local.schedule({
//add the Id of notification
id: 1,
text: "Delayed Notification",
at: new Date(new Date().getTime() + 5*1000)
});
Upvotes: 0