Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26103] iOS 12: Support grouped notifications

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2018-07-30T05:35:53.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.4.0
ComponentsiOS
Labelsn/a
ReporterHans Knöchel
AssigneeHans Knöchel
Created2018-06-06T03:55:00.000+0000
Updated2018-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.

Comments

  1. Hans Knöchel 2018-06-06

    PR: https://github.com/appcelerator/titanium_mobile/pull/10091
  2. Hans Knöchel 2018-07-28

    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'
           });
       }
       
  3. Christopher Williams 2018-08-27

    cherry picked fix to 7_4_X branch: https://github.com/appcelerator/titanium_mobile/commit/c352cb8c01f14d43e4f79c743afcfaa6f9d8ff18
  4. Samir Mohammed 2018-08-28

    *Closing ticket.* Verified fix in SDK version: 7.4.0.v20180827125633 and 7.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 notification

    Went 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*
       APPC Studio:  5.1.0.201808080937
       APPC CLI: 7.0.6-Master.5
       iphone 6 simulator (12.0)
       Operating System Name: Mac OS High Sierra
       Operating System Version: 10.13.6
       Node.js Version: 8.9.1
       Xcode 10.0 beta 6

JSON Source