{ "id": "153506", "key": "TIMOB-20111", "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": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2016-04-19T06:25:23.000+0000", "created": "2015-11-30T16:00:38.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "android", "pushnotification" ], "versions": [ { "id": "17532", "name": "Release 5.1.1", "archived": false, "released": true, "releaseDate": "2015-11-24" } ], "issuelinks": [], "assignee": { "name": "ssombhatla", "key": "ssombhatla", "displayName": "Srikanth Sombhatla", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2016-04-19T06:25:23.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "When a view is opened and app is placed into background, tapping on a push notification does not fire the trayClickFocusedApp event. This works fine if I don't open a window in the app. However, if even a single window is opened, trayClickFocusedApp stops working (I'm guessing this is due to the fact that there are more than a single activity if windows are opened). In the attached test code, simply comment out the following line and trayClickFocusedApp to start working again:\r\n\r\n{code:java}\r\n win.open(); \r\n{code}\r\n\r\nSteps to reproduce\r\n# Create a cloud enabled app\r\n#Paste the following into app.js\r\n\r\n{code:java}\r\nvar win = Titanium.UI.createWindow({\r\n\ttitle: 'Push Test',\r\n\tbackgroundColor: '#fff'\r\n});\r\n \r\nvar login = \"\"; // Replace with an ACS user login\r\nvar password = \"\"; // Replace with an ACS user password\r\n \r\n// If you comment out this line, everything works as expected\r\nwin.open();\r\n \r\n \r\n \r\n// --------------------------------------------------------------------------------\r\n//\r\n// Push notification stuff\r\n//\r\n// --------------------------------------------------------------------------------\r\n \r\nvar CloudPush = require('ti.cloudpush');\r\nCloudPush.debug = true;\r\nCloudPush.enabled = true;\r\n \r\nvar deviceToken;\r\nvar Cloud = require('ti.cloud');\r\n \r\nCloudPush.retrieveDeviceToken({\r\n\tsuccess: function deviceTokenSuccess(e) {\r\n\t\tTi.API.info('Device Token: ' + e.deviceToken);\r\n\t\tdeviceToken = e.deviceToken;\r\n\t\tloginDefault(deviceToken);\r\n\t},\r\n\terror: function deviceTokenError(e) {\r\n\t\tTi.API.error('Failed to register for push! ' + e.error);\r\n\t}\r\n});\r\n \r\nfunction loginDefault(e) {\r\n \r\n\tCloud.Users.login({\r\n\t\tlogin: login,\r\n\t\tpassword: password\r\n\t}, function(e) {\r\n\t\tif (e.success) {\r\n \r\n\t\t\tdefaultSubscribe();\r\n \r\n\t\t\t//Place app in background\r\n\t\t\tTi.Platform.openURL(\"http://www.appcelerator.com\");\r\n \r\n\t\t\t//Send a push in 2 seconds\r\n\t\t\tsetTimeout(function() {\r\n\t\t\t\tCloud.PushNotifications.notify({\r\n\t\t\t\t\tchannel: 'message',\r\n\t\t\t\t\tpayload: {\r\n\t\t\t\t\t\t\"badge\": 2,\r\n\t\t\t\t\t\t\"sound\": \"default\",\r\n\t\t\t\t\t\t\"alert\": \"Push Notification Test\",\r\n\t\t\t\t\t\t\"icon\": \"app_icon\"\r\n\t\t\t\t\t}\r\n\t\t\t\t}, function(e) {\r\n\t\t\t\t\tif (e.success) {\r\n\t\t\t\t\t\tTi.API.info('Success notify');\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tTi.API.error('Error:\\n' + ((e.error && e.message) || JSON.stringify(e)));\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}, 2000);\r\n\t\t} else {\r\n\t\t\tTi.API.error('Error:\\\\n' + ((e.error && e.message) || JSON.stringify(e)));\r\n\t\t}\r\n\t});\r\n \r\n}\r\n \r\nfunction defaultSubscribe() {\r\n \r\n\tCloud.PushNotifications.subscribe({\r\n\t\tchannel: 'message',\r\n\t\tdevice_token: deviceToken,\r\n\t\ttype: 'gcm'\r\n\t}, function(e) {\r\n\t\tif (e.success) {\r\n\t\t\tTi.API.info('Subscribed!');\r\n \r\n\t\t\tCloudPush.addEventListener('callback', function(evt) {\r\n\t\t\t\tTi.API.info(\"callback\" + JSON.stringify(evt));\r\n\t\t\t\talert('got the callback event');\r\n\t\t\t});\r\n \r\n\t\t\tCloudPush.addEventListener('trayClickFocusedApp', function(evt) {\r\n\t\t\t\tTi.API.info('Tray Click Focused App (app was already running)' + JSON.stringify(evt));\r\n\t\t\t\talert('got the trayClickFocusedApp event')\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\tTi.API.error('Error:' + ((e.error && e.message) || JSON.stringify(e)));\r\n\t\t}\r\n\t});\r\n}\r\n{code}\r\n\r\n# Set your login/password to a valid user (lines 6 & 7)\r\n# Launch the app on a device. The app should launch, fire off a push notification then go into the background by launching the browser.\r\n# Tap the notification to return to the app.\r\n\r\nExpected Results\r\nThe trayClickFocusedApp event listener should run and display a message.\r\n\r\nActual Results\r\nThe trayClickFocusedApp event listener does not run.", "attachment": [], "flagged": false, "summary": "Android: trayClickFocusedApp event not fired when push notification clicked in tray", "creator": { "name": "bradleycorn", "key": "bradleycorn", "displayName": "Brad Ball", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "bradleycorn", "key": "bradleycorn", "displayName": "Brad Ball", "active": true, "timeZone": "America/New_York" }, "environment": "Titanium SDK v 5.1.0.GA\r\nSamsung Galaxy S4\r\nAndroid 5.0.1\r\nMack OSX 10.10.5", "comment": { "comments": [ { "id": "377972", "author": { "name": "ssombhatla", "key": "ssombhatla", "displayName": "Srikanth Sombhatla", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~bradleycorn],\r\n\r\nIn the app.js L:53 when calling {{Cloud.PushNotifications.notify}} are you getting success response? Because that API expects {{to_ids}}.\r\nhttp://docs.appcelerator.com/arrowdb/latest/#!/api/PushNotifications-method-notify\r\n\r\nOnce I change it to current logged-in userid, I am getting {{trayClickFocusedApp}} event. Please verify and let me know. \r\n[~aislam] Please confirm.\r\n", "updateAuthor": { "name": "ssombhatla", "key": "ssombhatla", "displayName": "Srikanth Sombhatla", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-02-26T08:17:05.000+0000", "updated": "2016-02-26T08:17:51.000+0000" }, { "id": "378297", "author": { "name": "bradleycorn", "key": "bradleycorn", "displayName": "Brad Ball", "active": true, "timeZone": "America/New_York" }, "body": "@Srikanth, \r\n\r\nSorry, I posted a bad example. I DO get the trayClickFocusedApp event when running the sample above. \r\n\r\nI believe the issue (the event not getting fired) actually occurs when the app has more than one activity. I can put together a sample app to test and verify that, but it'll probably take a me a few weeks, because I'm swamped with other work at the moment.\r\n\r\nAgain, sorry for the bad sample posted in the ticket.", "updateAuthor": { "name": "bradleycorn", "key": "bradleycorn", "displayName": "Brad Ball", "active": true, "timeZone": "America/New_York" }, "created": "2016-03-01T14:58:09.000+0000", "updated": "2016-03-01T14:58:09.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }