[TIMOB-26339] iOS: Local notification not triggered when setting repeat (only 7.3.0.GA)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-08-29T06:43:37.000+0000 |
Affected Version/s | Release 7.3.0 |
Fix Version/s | Release 7.3.1 |
Components | iOS |
Labels | ios, notifications |
Reporter | Teun Klijn |
Assignee | Hans Knöchel |
Created | 2018-08-27T13:37:36.000+0000 |
Updated | 2018-11-07T09:26:22.000+0000 |
Description
I've noticed that local push notifications won't be shown when setting the repeat property, it does show when it's omitted. This seems to have started with SDK 7.3.0.GA.
Example:
var win = Ti.UI.createWindow({
backgroundColor: "white",
layout: "vertical"
});
var repeatSwitch = Ti.UI.createSwitch();
var btn = Ti.UI.createButton({
top: 50,
title: "Schedule"
});
btn.addEventListener("click", function() {
var not = {
date: new Date(new Date().getTime() + 3000),
alertTitle: 'Notification',
alertBody: 'This is a notification',
badge: 1,
userInfo: {
id: '1'
},
repeat: repeatSwitch.value ? "daily" : undefined
};
console.log('schedule: ' + JSON.stringify(not));
Ti.App.iOS.scheduleLocalNotification(not);
});
win.add(btn);
win.add(Ti.UI.createLabel({
text: "Repeat?"
}));
win.add(repeatSwitch);
win.addEventListener("open", function() {
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
]
});
});
win.open();
Attachments
File | Date | Size |
---|---|---|
TiAppiOSProxy.m | 2018-08-28T12:02:08.000+0000 | 50508 |
Hey there! We refactored the whole notifications-API to use the new UserNotifications framework in iOS 10+. Your issue sounds valid and we'll provide a fix for this early this week. Thank you!
PR (master): https://github.com/appcelerator/titanium_mobile/pull/10289 PR (7_4_X): https://github.com/appcelerator/titanium_mobile/pull/10291 PR (7_3_X): https://github.com/appcelerator/titanium_mobile/pull/10290 Test-Case: Above [~teunklijn@telfort.nl] Can you please do me a favor and replace the attached [^TiAppiOSProxy.m] in the following directory:
You can make a backup of the old file to be sure. Let me know if it works properly now! Spontaneously, I didn't find a way to test if the notification will be triggered 24 hours later, but the new code looked good :-).
The attached TiAppiOSProxy.m seems to be identical to the one that I already have, so the notification doesn't trigger yet. I've tried the one from the pull request, but that also doesn't trigger. I could have used the wrong one.
[~teunklijn@telfort.nl] Sorry, try again. It was the old one from an earlier Git revision.
It does work better now, the notification does trigger if you schedule only 1, but if you schedule 2 notifications in a row only the 2nd notification will appear. It doesn't matter if you set repeat or not, for example:
That probably happens because the default
identifier
is used if not explicitly set. I noticed that this only happens for the new UserNotifications framework on iOS 10+, so it may be an Apple bug or per design. A simple fix is to assign differentidentifier
strings to make them unique. This also helps to better manage pending / delivered notifications. *EDIT*: Confirmed to work with the following:That does indeed work! Thank you for your help.
I just pushed another commit to make notifications on iOS 10+ unique by default, to match the iOS < 10 behavior for now. It internally generates a UUID-string that is also injected into the "userInfo.id" if not already set, so it can be used to identifier them later again. Does that match your expectations of the API?
Yes that does match my expectations.
Verified fix in SDK version
7.5.0.v20180828231421
and7.3.1.v20180828234519
. *Test Steps FR*Created a new titanium project
Added the code from the description in to the application
Ran the program
Enabled scheduled push notifications
Pressed schedule
Went to the home screen
Able to see the push notifications trigger
Created a new application with the second test case in the comments
followed the steps above (3-7)
Able to see both notifications trigger
*Test Environment**Note:* Waiting for the 7_4_X build from Jenkins.
*Closing Ticket* Verified fix in SDK Version
7.4.0.v20180829012158
With the above steps.Hi, it seems like this has now broken the scheduling of local notification when you DO NOT set "repeat" The code below will never fire the notification