Steffaan / cordova-plugin-local-notifications

Cordova Local Notifications Plugin
Apache License 2.0
31 stars 38 forks source link

cordova.plugins.notification.local.schedule works first time, crashes every other time #16

Closed salem0426 closed 5 years ago

salem0426 commented 5 years ago

WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

First notification is successful. Every other notification crashes the app

Your Environment

Expected Behavior

Notification pop-ups work every time

Actual Behavior

First notification is successful. Every other notification crashes the app in UNUserNotificationCenter(APPLocalNotification) getNotificationWithID Line 131

Steps to Reproduce

Happens consistently

Context

Code snippet: cordova.plugins.notification.local.schedule({ title: 'PEARL Alert', text:inText, smallIcon: 'res://noti-logo.png', icon: 'file://img/noti-logo.jpg', vibrate:true, lockscreen:true, foreground: true, actions: [ acts function(data){ console.log("Notification callback: ",data); } ] });

Debug logs

Include iOS / Android logs

salem0426 commented 5 years ago

Additional information regarding Notifications working for the first time: Receives a one time only pop-up asking to allow Notifications for iOS Application image1-12

salem0426 commented 5 years ago

Neglected to indicate that this issue is with iOS devices only. Notifications for this App on Android phones works just fine.

Steffaan commented 5 years ago

The issue is in your code, debug your javascript and check if all your variables are set correct. Especially this piece of code:

actions: [
acts
function(data){
console.log("Notification callback: ",data);
}
]

What is acts ?

Steffaan commented 5 years ago

You need to provide the actions like this:

actions: [
                    { id: 'firstAction', title: 'Your first action' },
                    { id: 'secondAction', title: 'Your second action' }
]

And catch them like this:

cordova.plugins.notification.local.on('firstAction', function (data, eopts) {
            // Your code
});

cordova.plugins.notification.local.on('secondAction', function (data, eopts) {
            // Your code
});
salem0426 commented 5 years ago

Steffaan: Thank you for responding. I am looking to use cordova.plugins.notification.local.schedule to be called from my App with a message argument.

Every time the function is called, cordova.plugings.notification.local.schedule displays the message.

Currently, this only works for the initial call and not for any other calls.

Any suggestions on how to get this to work would be most appreciated! Thanks, salem0426