{ "id": "171963", "key": "TIMOB-26237", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "20220", "name": "Release 7.3.1", "archived": false, "released": true, "releaseDate": "2018-08-30" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-08-21T07:12:26.000+0000", "created": "2018-07-24T01:47:02.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "localnotification", "pushnotification" ], "versions": [ { "id": "19906", "description": "", "name": "Release 6.3.0", "archived": false, "released": true, "releaseDate": "2017-11-01" }, { "id": "20102", "name": "Release 7.1.1", "archived": false, "released": true, "releaseDate": "2018-05-02" }, { "id": "20099", "name": "Release 7.2.0", "archived": false, "released": true, "releaseDate": "2018-06-14" } ], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2018-09-19T21:03:18.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "If a local notification is shown and the user taps the notification, the app opens, but the notification event is not triggered. It is triggered just fine if the app has already been opened but is not currently active in the foreground.\r\n\r\nSample code - the alerts are never fired if tapping the notification is staring up the app: \r\n\r\n{code}\r\nTi.App.iOS.registerUserNotificationSettings({\r\n\ttypes: [\r\n\t\tTi.App.iOS.USER_NOTIFICATION_TYPE_ALERT\r\n\t]\r\n});\r\n\r\nTi.App.iOS.addEventListener('notification', function(e) {\r\n\talert('notification');\r\n});\r\n\r\nTi.App.iOS.addEventListener('localnotificationaction', function(e) {\r\n\talert('localnotificationaction');\r\n});\r\n\r\nTi.App.addEventListener('pause',function()\r\n{\r\n\tvar timestamp = new Date(new Date().getTime() + 10000);\r\n\r\n\t// The following code snippet schedules an alert to be sent within three seconds\r\n\tvar notification = Ti.App.iOS.scheduleLocalNotification({\r\n\t\tcategory: \"TEST\",\r\n\t\talertAction: 'Read now',\r\n\t\talertBody: 'Custom message',\r\n\t\tdate: timestamp,\r\n\t\trepeat: \"daily\",\r\n\t\t//The following URL is passed to the application\r\n\t\tuserInfo: {\r\n\t\t\t\"task\": \"test\"\r\n\t\t}\r\n\t});\r\n});\r\n{code}", "attachment": [], "flagged": false, "summary": "iOS: Local Notification Event not triggered when app is launched from the background", "creator": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "subtasks": [], "reporter": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "environment": "iPhone 8 Device + Simulator, Ti 6.3.0, 7.1.0, 7.2.0", "comment": { "comments": [ { "id": "439433", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Taken (and modified) from TIMOB-23527 (7.3.0), the following works fine:\r\n{code:js}\r\n// An action that opens the app (foreground action)\r\nvar acceptAction = Ti.App.iOS.createUserNotificationAction({\r\n identifier: 'ACCEPT_IDENTIFIER',\r\n title: 'Accept',\r\n activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_FOREGROUND,\r\n destructive: false,\r\n authenticationRequired: true\r\n });\r\n \r\n // An action that does not open the app (background action)\r\n var rejectAction = Ti.App.iOS.createUserNotificationAction({\r\n identifier: 'REJECT_IDENTIFIER',\r\n title: 'Reject',\r\n activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,\r\n destructive: true,\r\n authenticationRequired: false\r\n });\r\n \r\n // An action that does not open the app (background action), but lets the developer\r\n // type in a text (iOS 9+)\r\n var respondAction = Ti.App.iOS.createUserNotificationAction({\r\n identifier: 'RESPOND_IDENTIFIER',\r\n title: 'Respond',\r\n activationMode: Ti.App.iOS.USER_NOTIFICATION_ACTIVATION_MODE_BACKGROUND,\r\n behavior: Ti.App.iOS.USER_NOTIFICATION_BEHAVIOR_TEXTINPUT, // or: Ti.App.iOS.USER_NOTIFICATION_BEHAVIOR_DEFAULT,\r\n authenticationRequired: false\r\n });\r\n \r\n // Create an example notification category\r\n var downloadContent = Ti.App.iOS.createUserNotificationCategory({\r\n identifier: 'DOWNLOAD_CONTENT',\r\n actionsForDefaultContext: [acceptAction, rejectAction, respondAction]\r\n });\r\n \r\n // Register for user notifications and categories\r\n Ti.App.iOS.registerUserNotificationSettings({\r\n types: [\r\n Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT\r\n ],\r\n categories: [downloadContent]\r\n });\r\n \r\n // Monitor notifications received while app is in the background\r\n Ti.App.iOS.addEventListener('localnotificationaction', function(e) {\r\n alert('event: localnotificationaction');\r\n });\r\n \r\n Ti.App.iOS.addEventListener('usernotificationsettings', function(e) {\r\n alert('event: usernotificationsettings');\r\n })\r\n \r\n // Monitor notifications received while app is in the foreground\r\n Ti.App.iOS.addEventListener('notification', function(e) {\r\n alert('event: notification');\r\n });\r\n \r\n // App UI\r\n var win = Ti.UI.createWindow({\r\n backgroundColor: 'white'\r\n });\r\n var button = Ti.UI.createButton({\r\n title: 'Trigger Notification'\r\n });\r\n\r\n button.addEventListener('click', function(e) {\r\n // Send a notification in 3 seconds\r\n var note = Ti.App.iOS.scheduleLocalNotification({\r\n date: new Date(new Date().getTime() + 3000),\r\n alertTitle: 'My download',\r\n alertSubtitle: 'Check it out!',\r\n alertBody: 'New content available! Download now?',\r\n badge: 1,\r\n userInfo: {\r\n 'url': 'http://www.download.com/resource/asset.json',\r\n id: '1'\r\n },\r\n category: 'DOWNLOAD_CONTENT'\r\n });\r\n });\r\n \r\n win.add(button);\r\n win.open();\r\n{code}", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-07-24T05:53:45.000+0000", "updated": "2018-07-24T05:54:19.000+0000" }, { "id": "439434", "author": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "body": "Thanks for the quick reply Hans! To clarify (without having played with your code yet), does the link to TIMOB-23527 (7.3.0) mean that I need to wait for 7.3.0 for this to work? Or it should already work ok in 7.2.0 & 7.1.0 etc?", "updateAuthor": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "created": "2018-07-24T06:47:27.000+0000", "updated": "2018-07-24T06:47:27.000+0000" }, { "id": "439436", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "I tried with 7.3.0, but it's also supposed to work in <= 7.2.0. *EDIT*: Just tested with 7.2.0, works fine as well. Please compare the code to identify the issue for you. Thanks!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-07-24T08:30:03.000+0000", "updated": "2018-07-24T08:31:51.000+0000" }, { "id": "439449", "author": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "body": "I am not having any luck here Hans.\r\n\r\nTo be clear, the issue is about the notification event not being fired +from a fresh launch+.\r\n\r\nI have disabled the eventListener for *usernotificationsettings* as this always fires when the app is opened even if a notification has not been triggered. And from what I can see it is not relevant to a +specific+ notification being triggered by the user.\r\n\r\nDoing this step by step using your sample code...\r\n\r\nThis process *works ok*:\r\n\r\n1. Open the app\r\n2. Click the \"Trigger Notification\" button\r\n3. Home button once\r\n4. Notification appears - click to Open. Note: Don't trigger the Accept/Reject/Respond, just tap the notification once to Open the app.\r\n5. App opens and the alert \"event: notification\" appears\r\n\r\nThis process *does not work*:\r\n\r\n1. Open the app\r\n2. Click the \"Trigger Notification\" button\r\n3. Home button twice, to force close the app\r\n4. Notification appears - click to Open. Note: Don't trigger the Accept/Reject/Respond, just tap the notification once to Open the app.\r\n5. App opens - no alert is triggered\r\n\r\nI was testing with a clean app using 7.2.0 SDK.\r\n\r\nCan you let me know what is different for you? Does the second process, after a force close, work ok for you? \r\n\r\nOr am I missing something?", "updateAuthor": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "created": "2018-07-24T21:26:48.000+0000", "updated": "2018-07-24T21:35:08.000+0000" }, { "id": "439491", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey there, you have been right! This is a quite edgy case that doesn't seem to be handled so far. I tested out a fix locally and it works fine. I will try to get it into 7.3.1 (as 7.3.0 is due next week already), but will also provide you a patch that you can apply today to test it out. More soon!", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-07-26T07:47:18.000+0000", "updated": "2018-07-26T07:47:18.000+0000" }, { "id": "439492", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR (master): https://github.com/appcelerator/titanium_mobile/pull/10213\r\nPR (7_3_X): https://github.com/appcelerator/titanium_mobile/pull/10215\r\n\r\nTest-Case: In the comments above", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-07-26T08:20:07.000+0000", "updated": "2018-07-26T10:30:40.000+0000" }, { "id": "439556", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Master merged, 7.3.1 will be merged once 7_3_X is bumped.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-07-27T17:43:57.000+0000", "updated": "2018-07-27T17:43:57.000+0000" }, { "id": "440988", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Verified fixed and changes are included in SDK builds 7.3.1.v20180821233955 & 7.4.0.v20180822015105", "updateAuthor": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2018-08-22T15:16:22.000+0000", "updated": "2018-08-22T15:16:22.000+0000" }, { "id": "441628", "author": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "body": "Unfortunately there is a bug with this fix. The fix is working perfectly, until one scenario...\r\n\r\nIf the notification has the optional `sound` parameter set, then when the notification event is triggered, the following error is thrown...\r\n\r\n{noformat}\r\n[ERROR] Application raised an exception: -[UNNotificationSound boundBridge:withKrollObject:]: unrecognized selector sent to instance 0x600003336d00`\r\n{noformat}\r\n\r\nAnd the \"localnotificationaction\" event listener is not triggered.\r\n\r\nIf the notification has the sound parameter removed, then everything works as expected.\r\n\r\nUnfortunately my app does have the sound parameter defined, and my users are well trained to hear the alert sound. If there is any chance this could be fixed as soon as possible I would be profoundly grateful :)\r\n\r\nTo clarify here is the same notification as shown in the sample code above, but with the sound parameter defined:\r\n\r\n{code:java}\r\nbutton.addEventListener('click', function(e) {\r\n // Send a notification in 3 seconds\r\n var note = Ti.App.iOS.scheduleLocalNotification({\r\n date: new Date(new Date().getTime() + 3000),\r\n alertTitle: 'My download',\r\n alertSubtitle: 'Check it out!',\r\n alertBody: 'New content available! Download now?',\r\n sound: \"/alert.wav\", // <<<<< This causes an issue\r\n badge: 1,\r\n userInfo: {\r\n 'url': 'http://www.download.com/resource/asset.json',\r\n id: '1'\r\n },\r\n category: 'DOWNLOAD_CONTENT'\r\n });\r\n});\r\n{code}\r\n", "updateAuthor": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "created": "2018-09-17T19:56:01.000+0000", "updated": "2018-09-17T19:56:01.000+0000" }, { "id": "441629", "author": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "body": "Further to my above comment, in same cases this error will crash the app.", "updateAuthor": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "created": "2018-09-17T19:58:52.000+0000", "updated": "2018-09-17T19:58:52.000+0000" }, { "id": "441814", "author": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "body": "I have created a new ticket for the issue: AC-5901", "updateAuthor": { "name": "mdelmarter", "key": "mdelmarter", "displayName": "Matthew Delmarter", "active": true, "timeZone": "Pacific/Auckland" }, "created": "2018-09-19T21:03:18.000+0000", "updated": "2018-09-19T21:03:18.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }