{ "id": "142505", "key": "TIMOB-18390", "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": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2015-03-26T23:35:27.000+0000", "created": "2015-01-08T11:49:31.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "TCSupport", "ios", "push", "pushnotification" ], "versions": [ { "id": "16676", "description": "Release 3.4.1", "name": "Release 3.4.1", "archived": false, "released": true, "releaseDate": "2014-11-14" }, { "id": "16704", "description": "Release 3.5.0", "name": "Release 3.5.0", "archived": false, "released": true, "releaseDate": "2015-01-13" } ], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-24T18:02:42.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": "h4. Problem Description\r\nI've discovered a bug where the app crashes when it receives some (3+) push notifications while the iPhone's screen is turned off and the app is in background.\r\n\r\nh4. Steps to reproduce \r\n1. Create a new mobile project\r\n2. Add this code to the app via app.js\r\n{code}\r\nvar win = Ti.UI.createWindow({backgroundColor:\"green\"});\r\nwin.open();\r\n\r\nvar callbacks = {\r\n types: [\r\n Titanium.Network.NOTIFICATION_TYPE_BADGE,\r\n Titanium.Network.NOTIFICATION_TYPE_SOUND,\r\n Titanium.Network.NOTIFICATION_TYPE_ALERT\r\n ],\r\n success:function(e){\r\n console.log(\"SUCCESS\",e.deviceToken);\r\n subscribeACS(e.deviceToken);\r\n },\r\n error:function(e){\r\n console.log(\"ERROR\",new Date().toTimeString());\r\n },\r\n callback: function(e){\r\n console.log(\"CALLBACK\",new Date().toTimeString());\r\n }\r\n};\r\n\r\nif(Ti.App.iOS.registerUserNotificationSettings){ \r\n function onUserNotificationSettings(){\r\n delete callbacks.types;\r\n Ti.Network.registerForPushNotifications(callbacks);\r\n Ti.App.iOS.removeEventListener(\"usernotificationsettings\",onUserNotificationSettings);\r\n }\r\n Ti.App.iOS.addEventListener(\"usernotificationsettings\",onUserNotificationSettings)\r\n Ti.App.iOS.registerUserNotificationSettings(callbacks)\r\n}else{\r\n Ti.Network.registerForPushNotifications(callbacks)\r\n}\r\n\r\n\r\nfunction subscribeACS(token){\r\n\tvar Cloud = require('ti.cloud');\r\n\tCloud.PushNotifications.subscribeToken({\r\n\t channel: 'testChannel',\r\n\t device_token: token\r\n\t}, function (e) {\r\n\t if (e.success) {\r\n\t alert('Success');\r\n\t } else {\r\n\t alert('Error:\\n' +\r\n\t ((e.error && e.message) || JSON.stringify(e)));\r\n\t }\r\n\t});\r\n}\r\n{code}\r\n3. Please replace the ACS keys with your own and the GUID with your own. \r\n4. Install to device\r\n{code}ti build -p ios -T device{code}\r\n5. Open App\r\nAllow it to retrieve a device token (used below)\r\n6. Send 2 notifications\r\n{code}for i in `seq 1 2`; do curl -X POST -F \"channel=testChannel\" -F \"to_tokens=\" -F \"payload=$i\" \"https://api.cloud.appcelerator.com/v1/push_notification/notify_tokens.json?key=&pretty_json=true\";done{code}\r\n7. You'll see \"CALLBACK...\" in console logs\r\n8. Background app with home button\r\n9. Send 3+ noticiations\r\n{code}for i in `seq 1 3`; do curl -X POST -F \"channel=testChannel\" -F \"to_tokens=\" -F \"payload=$i\" \"https://api.cloud.appcelerator.com/v1/push_notification/notify_tokens.json?key=&pretty_json=true\";done{code}\r\n10. You should now get the crash in the console\r\n\r\n\r\n\r\nh4. Extra information\r\nAfter some push notifications, the 'callback' function does not get called anymore. After that, when I turn the screen back on, the app crashes completely with an error in the console.\r\n\r\nThis happens on at least iPhone 5S, iPhone 6 and iPhone 6 Plus and is a critical bug since it prevents users from receiving important notifications!\r\n\r\nI've put together an example app & server and closely documented this issue at: https://github.com/VanCoding/iOS-Push-Bug\r\n\r\nUsing this you can reproduce this error on your own.\r\n\r\nI'm using SDK 3.4.0.GA btw.", "attachment": [ { "id": "53707", "filename": "crash_log.txt", "author": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-19T18:09:14.000+0000", "size": 2285, "mimeType": "text/plain" }, { "id": "53601", "filename": "tc 2.zip", "author": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-14T23:08:18.000+0000", "size": 2461545, "mimeType": "application/zip" } ], "flagged": false, "summary": "iOS: App crashes after receiving some push notifications in background", "creator": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "iOS, iPhone 5, iPhone 5s, iPhone6, iPhone 6 Plus\r\niPhone 6 on iOS 8.1.1 and 8.1.2\r\niPhone 6+ on iOS 8.0.2\r\niPhone 5 on 8.1\r\nMobile SDK 3.5.0 and 3.4.1", "closedSprints": [ { "id": 362, "state": "closed", "name": "2015 Sprint 06 SDK", "startDate": "2015-03-14T13:56:53.868Z", "endDate": "2015-03-28T00:00:00.000Z", "completeDate": "2015-03-30T17:32:33.590Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "338508", "author": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello [~VanCoding],\r\n\r\nI had difficulty testing this and will try again tomorrow. Curious, have you tried 3.4.1.GA?\r\n\r\n- Seth", "updateAuthor": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-09T05:30:50.000+0000", "updated": "2015-01-09T05:30:50.000+0000" }, { "id": "338513", "author": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Seth\r\n\r\nI've now tried it with 3.4.1.GA. It's exactly the same :(\r\n\r\nPlease let me know what difficutlies you have, I of course will help you with every single step, if needed.\r\nThis bug is actually preventing me from publishing my app to the app store since our customer does not want the app to be published with this problem still existing.\r\nSo I'm a bit in a hurry to fix this and of course have every time you need to me to help you.\r\n\r\nSadly, you still have to generate the certificates & provisioning profiles on you own due to apples stupid polices... :(\r\n\r\nThanks for working on this issue!", "updateAuthor": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-09T08:14:51.000+0000", "updated": "2015-01-09T08:20:57.000+0000" }, { "id": "338657", "author": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Seth\r\n\r\nNow that the weekend's over I'm curious if you were able to reproduce the bug.\r\nYou said that you'll try again. Have you already done it?\r\n\r\nThanks :)", "updateAuthor": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-12T08:47:48.000+0000", "updated": "2015-01-12T08:47:48.000+0000" }, { "id": "338712", "author": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello [~VanCoding], \r\n\r\nI'm not entirely sure how to create the pfx you want in your setup step 2. Do I need to use keychain access to create it? Since I'm having trouble using your script I'll use our [ACS|http://docs.appcelerator.com/cloud/latest/#!/api/PushNotifications-method-notify_tokens] notify API to send push notifications in the same frequency. I'll let you know what happens. \r\n\r\nThank you,\r\nSeth", "updateAuthor": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-12T19:28:20.000+0000", "updated": "2015-01-12T19:36:27.000+0000" }, { "id": "338721", "author": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello [~VanCoding] ,\r\n\r\nHere is my test:\r\n\r\nDevice: iPhone 6 (8.1.1)\r\nSDK: 3.4.1.GA\r\n\r\n1. Open app, green screen shows, I receive device id in logs\r\n2. I lock the phone and send 5 push notifications it quick succession. \r\n3. I do not see any callbacks fired while device is locked. I do however see the callbacks if I repeat these steps while the app is open (expected behavior). \r\n\r\nI also see the callback if my device is locked, and I swipe to open a specific notification. \r\n\r\nI can share my slightly modified revision of your code (for using ACS) if you like. ", "updateAuthor": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-12T19:58:36.000+0000", "updated": "2015-01-12T20:00:42.000+0000" }, { "id": "338743", "author": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Seth\r\n\r\nThat's strange!\r\nAs described at the top, I DO get callbacks fired when the device is locked/the app is in background. But after some notifications (this can neen more than 5 notifications, but usually already happens after 3) i stop receiving them. And then, when I unlock the phone (and not open a specific notification), I get the error I mentioned and the app crashes.\r\n\r\nIts actually easy to generate the pfx file using \"openssl pkcs12 -export -in my.cer -inkey my.key -out mycert.pfx\", make sure the key and the certificate are both in the pem format.\r\nI'm of course interested in your code, maybe it's a problem with the way that node-apn sends the notifications, who knows.\r\n\r\nBut the problem really exists. I've tried iPhone 5S, iPhone 6 & iPhone 6 Plus, so... :S", "updateAuthor": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-12T21:47:16.000+0000", "updated": "2015-01-12T21:47:16.000+0000" }, { "id": "338753", "author": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~VanCoding],\r\nDo you leave the app and lock the device or just lock the device?\r\n\r\nWhile i work on creating the pfx you might want to check that your payload matches our documentation:\r\nhttp://docs.appcelerator.com/cloud/latest/#!/api/PushPayload\r\n\r\nThanks,\r\nSeth", "updateAuthor": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-12T22:55:20.000+0000", "updated": "2015-01-12T22:55:20.000+0000" }, { "id": "338771", "author": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It actually does not matter if i first put the app to the background and then lock, or just lock. The app crashes as soon as it resumes either thorugh unlocking the screen (when the app was not paused before) or resuming the app.\r\n\r\nAs you can see in my litte node-apn server, the payload should be okay. Nothing special about it :/\r\n\r\nIt's really strange that I get this error on all devices and you don't...\r\n\r\nThank you very much for checking it!", "updateAuthor": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-13T00:03:40.000+0000", "updated": "2015-01-13T00:03:40.000+0000" }, { "id": "338788", "author": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hello [~VanCoding],\r\n\r\nI was able to recreate your crash with your node script and our ACS push notifications. \r\nIt looks like a problem when using {code}UIBackgroundModes{code} in Tiapp.xml. The problem disappears entirely if it is removed (possible temporary solution for you). \r\n\r\nAnd the error only occurs for x ≥ 3 messages while the app is backgrounded. I'll get some additional eyes on this issue. ", "updateAuthor": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-13T00:36:33.000+0000", "updated": "2015-01-13T00:36:33.000+0000" }, { "id": "338852", "author": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Seth\r\n\r\nI'm so glad that you cloud reproduce the bug and are now looking forward to fix it.\r\n\r\nSadly, removing the UIBackgroundModes flag also means not receiving push notifications when the app is in background anymore. So that's not really a workaraound :(\r\nThe only option I have is to wait until this bug gets fixed, which I hope will be the case as soon as possible.\r\n\r\nThanks for your work, Seth :)", "updateAuthor": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-13T13:16:14.000+0000", "updated": "2015-01-13T13:16:14.000+0000" }, { "id": "338922", "author": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~VanCoding],\r\nMight be worth exploring http://docs.appcelerator.com/titanium/latest/#!/guide/iOS_Background_Services to see if it still errors with that. ", "updateAuthor": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-13T19:24:10.000+0000", "updated": "2015-01-13T19:24:10.000+0000" }, { "id": "339203", "author": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "My customer forces me to ask you for the deadline until when this issue will be fixed. Can you give me an expected fix date?\r\nThank you very much!", "updateAuthor": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-15T08:14:02.000+0000", "updated": "2015-01-15T08:14:02.000+0000" }, { "id": "339292", "author": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~VanCoding], some of our team members are still working on the test cases so it might be several weeks at this point. ", "updateAuthor": { "name": "stoda", "key": "stoda", "displayName": "Seth Toda", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-15T20:05:02.000+0000", "updated": "2015-01-15T20:05:02.000+0000" }, { "id": "339902", "author": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Dear Seth Toda, thank you for your reply. We do have a deadline from our customer to let the app work by end of January. It would be really great if you can help us with this matter so that we will not get in trouble with our customer. Thank you very much in advance.", "updateAuthor": { "name": "VanCoding", "key": "vancoding", "displayName": "Patrik Stutz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-01-20T16:33:00.000+0000", "updated": "2015-01-20T16:33:00.000+0000" }, { "id": "346181", "author": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "body": "If I'm not mistaken, removing the UIBackgroundModes 'remote-notifications' should not affect the app receiving push notifications in background. It will continue to work. See http://docs.appcelerator.com/titanium/latest/#!/guide/Subscribing_to_push_notifications-section-37551717_Subscribingtopushnotifications-ObtainingadevicetokenoniOS for how to receive push notifications on iOS 7 and > iOS8. Once push notifications are received in background or foreground, by pressing on the notification, it will bring the app to the foreground and proceed to the callback 'receivePush'.\r\n\r\nUnless you want to do something in the background when the notification is received, you will want to explore notification actions that will allow this in > iOS8. Example here: http://docs.appcelerator.com/titanium/latest/#!/guide/iOS_Interactive_Notifications", "updateAuthor": { "name": "cng", "key": "cng", "displayName": "Chee Kiat Ng", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-03-17T08:07:14.000+0000", "updated": "2015-03-18T01:23:09.000+0000" }, { "id": "415616", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid with reference to the above comments.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-24T18:02:42.000+0000", "updated": "2017-03-24T18:02:42.000+0000" } ], "maxResults": 25, "total": 25, "startAt": 0 } } }