[TIMOB-9481] iOS: cancelLocalNotification on iOS is broken
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-05-02T21:41:43.000+0000 |
Affected Version/s | Release 2.0.2, Release 3.4.0 |
Fix Version/s | Release 2.1.0, Sprint 2012-12 API |
Components | iOS |
Labels | api, ios8, module_notification_manager, qe-3.4.0, qe-testadded, regression |
Reporter | Anirudh Nagesh |
Assignee | Jon Alter |
Created | 2012-06-11T11:12:10.000+0000 |
Updated | 2017-05-02T21:41:43.000+0000 |
Description
In 'bg.js' of kitchensink, notifications cannot be cancelled using 'id' passed as userinfo dictionary to the notification.
{panel:title=bg.js}
var notification = Ti.App.iOS.scheduleLocalNotification({
alertBody:"Kitchen Sink was put in background",
alertAction:"Re-Launch!",
userInfo:{id:"1"},
sound:"pop.caf",
date:new Date(new Date().getTime() + 3000) // 3 seconds after backgrounding
});
// we cancel our notification if we don't want it to continue
// notification.cancel(); //this works!!!!
Ti.App.iOS.cancelLocalNotification("1");// this does not work.
This is fixed by Pedro and the fix is available here.
https://gist.github.com/48a765c50f64aa7c47ed
Pull Request: https://github.com/appcelerator/titanium_mobile/pull/2383
Pull merged. Kudos to Pedro.
Closing issue Tested with Ti Studio build 2.1.0.201206172244 Ti Mobile SDK 2.1.0.v20120618154152 hash r7830c03d OSX Lion 10.7.3 iPhone 4S OS 5.1 The expected behavior is shown
The cancelLocalNotification is not working on iOS8 device. It works fine for the same build on iOS 7.1 device. Tested On: SDK: 3.4.0.v20140829184521, 3.3.0.GA Studio: 3.4.0.201408291834 CLI: 3.4.0-dev Xcode: Xcode 6 Beta6, XCode5.1.1 Device: iPhone 5S (v8.0), iPhone 4 (v7.1) While testing on iOS 8, the notification sometimes might not come the first time or might take time. On second try it shows the notification despite of cancelLocalNotification
Why aren't we fixing this?
This is an iOS 8 issue that is easily worked around. When we schedule a notification, it does not immediately show up in the list of scheduled notifications. Because of this, when we callcancelLocalNotification
immediately after scheduling a notification, the new notification does not show up in the list of scheduled notifications and therefor can not be cancelled.Alternatives
1. Do not callcancelLocalNotification
immediately after scheduling the notification, but set a small timeout first. See the example code below. 2. Call thecancel
method no the notification object returned byscheduleLocalNotification
.Resolving ticket as Invalid as there is now a new version of Kitchen Sink available and we no longer support the version which relates to this ticket.