description
Schedule Local Notification shows duplicate Notification for iOS but it works as expected on android.
Steps to reproduce
1. Create a new project.
2. Paste the code on app.js file
3. Mention the time after 5 or any minutes and then install the app on the device.
4. Beofre it reaches 5 minutes kill the app multiple times
5. For Example: If I kill the app for 2 times, then it is displaying the notification two times.
6. But it should only one.
Test Code
var win = Ti.UI.createWindow({
});
if (Ti.Platform.name == "iPhone OS" && parseInt(Ti.Platform.version.split(".")[0]) >= 8) {
Ti.App.iOS.registerUserNotificationSettings({
types : [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE]
});
var notification = Ti.App.iOS.scheduleLocalNotification({
// Alert will display 'slide to update' instead of 'slide to view'
// or 'Update' instead of 'Open' in the alert dialog
alertAction : "update",
// Alert will display the following message
alertBody : "New content available! Update now?",
// The badge value in the icon will be changed to 1
badge : 1,
repeat : 'daily',
// Alert will be sent in three seconds
date : new Date(new Date().getTime() + 300000),
// The following sound file will be played
});
}
// Fired when the application receives an incoming local notification when it's in the foreground
Ti.App.iOS.addEventListener('notification', function(e) {
// Reset the badge value
if (e.badge > 0) {
Ti.App.iOS.scheduleLocalNotification({
date : new Date(new Date().getTime()),
badge : -1
});
}
});
win.open();
Thanks
So from what I'm understanding the issue is that you can get multiple calls if you close the app and re-open ? If so then that's to be expected, once you open the app the notification is scheduled. If you keep closing and re-opening the app you will schedule multiple notifications. Also in your javascript code, you're scheduling a new notification every time you receive one.
Closing ticket with reference to the previous comments.