Trigger event does not work when the application is in the background
See original GitHub issueI’m trying to generate (many, too many) local notifications from time to time, but due to the amount of notifications, I make them one by one, generating the first one, and with the trigger event, generating the next one, so that the application doesn’t crash. It works fine while the application is open, but when you move to the background, the trigger event stops working. I tried the cordova-plugin-background-mode plugin but it still doesn’t work. Is there a solution?
- Plugin version: 0.9.0-beta.1
- Platform: ios
- OS version: 11.1.2
- Device manufacturer / model: iPad and iPhone 5s
- Cordova version (
cordova -v
): 6.5.0 - Cordova platform version (
cordova platform ls
): ios 4.3.1 - Plugin config
- Ionic Version (if using Ionic)
Expected Behavior
When a local confirmation is triggered, the following must be generated with the trigger event
Actual Behavior
When you move to the background, no trigger event is triggered, therefore future local notifications are not generated.
Steps to Reproduce
document.addEventListener(‘deviceready’, function () {
cordova.plugins.notification.local.on("trigger",function(notificacion,b){
var datos_alerta={
id: 1,
title: "a title 2",
text: "a text 2",
trigger:{
at: //some date in the future
}
};
cordova.plugins.notification.local.schedule(datos_alerta);
});
cordova.plugins.notification.local.schedule({ id: 1, title: “a title”, text: “a text”, trigger:{ at://some date in the future } }); });
Context
I need to generate a local notification every time one is run, to update it with a new time
Issue Analytics
- State:
- Created 6 years ago
- Comments:18 (5 by maintainers)
Top GitHub Comments
As mentioned you need to add
launch: true
to the action-properties. And you should check launchDetails at every App-Start to recognise if the App was started by a local-notification (or one of its actions).launchDetails
does hold the notification-id and the event name (your action-id).If you set the notification-id by yourself and need to recognise it later, be sure to use an 32-bit Integer.
@ammichael
See here https://github.com/katzer/cordova-plugin-local-notifications#properties-1. Use the
launch
property for actions.