[AC-4516] Ti.App.iOS.scheduleLocalNotification not working with iOS 10
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Resolved |
| Resolution | Not Our Bug |
| Resolution Date | 2016-09-28T16:26:19.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | Titanium SDK & CLI |
| Labels | ios, ios-10 |
| Reporter | Dharshana Jayamaha |
| Assignee | Shak Hossain |
| Created | 2016-09-28T02:15:26.000+0000 |
| Updated | 2016-09-29T03:10:43.000+0000 |
Description
in iOS 10 scheduleLocalNotification are not working
tested bellow code with iOS 9.x and its works as expected.
with TI sdk 5.5 and its working but not with iOS 10
// Some comments here
Ti.App.iOS.scheduleLocalNotification({
date: new Date(new Date().getTime()),
alertBody: "Hello",
alertAction: "Re-Launch!",
badge: 1,
sound:"pop.caf",
});
You need to register the notification-settings beforehand, like state din our [guides](http://docs.appcelerator.com/platform/latest/#!/guide/iOS_Local_Notifications). Full example:
// Create notification actions var acceptAction = Ti.App.iOS.createUserNotificationAction({ identifier: "ACCEPT_IDENTIFIER", title: "Accept", activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_FOREGROUND, destructive: false, authenticationRequired: true }); var rejectAction = Ti.App.iOS.createUserNotificationAction({ identifier: "REJECT_IDENTIFIER", title: "Reject", activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND, destructive: true, authenticationRequired: false }); // Create a notification category var downloadContent = Ti.App.iOS.createUserNotificationCategory({ identifier: "DOWNLOAD_CONTENT", actionsForDefaultContext: [acceptAction, rejectAction] }); // Register for user notifications and categories Ti.App.iOS.registerUserNotificationSettings({ types: [ Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND ], categories: [downloadContent] }); // Monitor notifications received while app is in the background Ti.App.iOS.addEventListener('localnotificationaction', function(e) { if (e.category == "DOWNLOAD_CONTENT" && e.identifier == "ACCEPT_IDENTIFIER") { Ti.API.warn("start download"); } // Reset the badge value if (e.badge > 0) { Ti.App.iOS.scheduleLocalNotification({ date: new Date(new Date().getTime() + 3000), badge: "-1" }); } Ti.API.warn(e); Ti.API.warn("event: localnotificationaction"); }); Ti.App.iOS.addEventListener("usernotificationsettings", function(e) { Ti.API.warn("event: usernotificationsettings"); }) // Monitor notifications received while app is in the foreground Ti.App.iOS.addEventListener('notification', function(e) { Ti.API.warn("event: notification"); }); // App UI var win = Ti.UI.createWindow({backgroundColor: 'white'}); var button = Ti.UI.createButton({title: 'Trigger Notification'}); button.addEventListener('click', function(e){ // Send a notification in 3 seconds var note = Ti.App.iOS.scheduleLocalNotification({ date: new Date(new Date().getTime() + 3000), alertTitle: "My download", alertSubtitle: "Check it out!", alertBody: "New content available! Download now?", badge: 1, attachments: [{ identifier: "my_attachment", url: "default_app_logo.png" },{ identifier: "my_attachment2", url: "default_app_logo.png" }], userInfo: {"url": "http://www.download.com/resource/asset.json", id:"1"}, category: "DOWNLOAD_CONTENT" }); }); win.add(button); win.open();@hans Actually i have register the nofitication-settings beforehand. As i mention this issue only in iOS 10. and I also tested code sample you have posted above in iOS 9 and iOS 10 with TI SDK 5.5 result :: iOS 9, I function works as expected. iOS 10, function not working