Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23581] iOS: Schedule a Local Notification shows duplicate notification.

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionNot Our Bug
Resolution Date2016-08-08T16:23:30.000+0000
Affected Version/sRelease 5.3.0
Fix Version/sn/a
ComponentsiOS
LabelsiOS, schedulelocalnotification
ReporterMotiur Rahman
AssigneeAngel Petkov
Created2016-06-30T21:14:07.000+0000
Updated2017-03-24T18:55:33.000+0000

Description

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

Comments

  1. Angel Petkov 2016-07-27

    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.
  2. Lee Morris 2017-03-24

    Closing ticket with reference to the previous comments.

JSON Source