[TIMOB-26103] iOS 12: Support grouped notifications
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2018-07-30T05:35:53.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 7.4.0 |
| Components | iOS |
| Labels | n/a |
| Reporter | Hans Knöchel |
| Assignee | Hans Knöchel |
| Created | 2018-06-06T03:55:00.000+0000 |
| Updated | 2018-08-28T09:52:23.000+0000 |
Description
iOS 12 adds a couple of cool API's to improve the default grouping of notifications, e.g. by using thread identifiers and category summaries.
PR: https://github.com/appcelerator/titanium_mobile/pull/10091
Demo-Code:
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); var btn = Ti.UI.createButton({ title: 'Schedule Notification' }); btn.addEventListener('click', function() { schedule('id_1', 'New Notification', 'Hey there!', new Date().getTime() + 3000); schedule('id_2', 'Another Notification', 'Aloooah!', new Date().getTime() + 4000); schedule('id_3', 'Anooooother Notification', 'Hola!', new Date().getTime() + 5000); schedule('id_4', 'One more okay?', 'Hello!', new Date().getTime() + 6000); schedule('id_5', 'This is the last one', 'Hallo!', new Date().getTime() + 7000); }); win.add(btn); win.open(); var acceptAction = Ti.App.iOS.createUserNotificationAction({ identifier: 'ACCEPT_IDENTIFIER', title: 'Accept', activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_FOREGROUND, destructive: false, authenticationRequired: true }); // An action that does not open the app (background action) var rejectAction = Ti.App.iOS.createUserNotificationAction({ identifier: 'REJECT_IDENTIFIER', title: 'Reject', activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND, destructive: true, authenticationRequired: false }); // An action that does not open the app (background action), but lets the developer // type in a text (iOS 9+) var respondAction = Ti.App.iOS.createUserNotificationAction({ identifier: 'RESPOND_IDENTIFIER', title: 'Respond', activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND, behavior: Ti.App.iOS.USER_NOTIFICATION_BEHAVIOR_TEXTINPUT, // or: Ti.App.iOS.USER_NOTIFICATION_BEHAVIOR_DEFAULT, authenticationRequired: false }); // Create an example notification category var downloadContent = Ti.App.iOS.createUserNotificationCategory({ identifier: 'DOWNLOAD_CONTENT', actionsForDefaultContext: [acceptAction, rejectAction, respondAction] }); // Register for user notifications and categories Ti.App.iOS.registerUserNotificationSettings({ types: [ Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT ], categories: [downloadContent] }); // Monitor notifications received while app is in the background Ti.App.iOS.addEventListener('localnotificationaction', function(e) { alert('event: localnotificationaction'); }); // Validate notification settings Ti.App.iOS.addEventListener('usernotificationsettings', function(e) { Ti.API.info('event: usernotificationsettings'); }) // Monitor notifications received while app is in the foreground Ti.App.iOS.addEventListener('notification', function(e) { alert('event: notification'); }); function schedule(identifier, title, body, date) { Ti.App.iOS.scheduleLocalNotification({ identifier: identifier, alertTitle: title, alertBody: body, summaryArgument: 'My Summary', summaryArgumentCount: 2, threadIdentifier: 'my_thread', date: date, category: 'DOWNLOAD_CONTENT' }); }cherry picked fix to 7_4_X branch: https://github.com/appcelerator/titanium_mobile/commit/c352cb8c01f14d43e4f79c743afcfaa6f9d8ff18
*Closing ticket.* Verified fix in SDK version:
7.4.0.v20180827125633and7.5.0.v20180827102657.*Test Steps (FR Passed):*Created a new titanium project
Added the code above in to the project
Ran the program ensuring newest beta of XCode is installed along with IOS 12. beta
Pressed
schedule notificationWent to Home screen
Waited for the notifications to appear
Pulled down on the screen to view notifications and saw that they were grouped
*Test Environment*