{ "id": "154141", "key": "TIMOB-20291", "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": "10100", "description": "This issue won't be actioned.", "name": "Won't Do" }, "resolutiondate": "2019-11-15T22:30:15.000+0000", "created": "2016-01-06T12:15:44.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "ANDROID", "AWS", "Appcelerator", "Notifications", "Push", "SNS" ], "versions": [], "issuelinks": [], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2019-11-15T22:30:15.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": "h6.Issue Description\r\nWhile sending push notifications from aws dashboard or my api, android doesnt detect any payload received. And if the application is in background the application crashes with the following stacktrace:\r\n\r\n{code}\r\n[ERROR] : APSCloudPush: Payload is null!\r\n[ERROR] : TiApplication: (main) [727118,839001] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.GCMReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference; Titanium 5.2.0,2015/11/25 11:26,1edba8d\r\n[ERROR] : TiApplication: java.lang.RuntimeException: Unable to start receiver com.appcelerator.aps.GCMReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread.handleReceiver(ActivityThread.java:2776)\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread.-wrap14(ActivityThread.java)\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440)\r\n[ERROR] : TiApplication: \tat android.os.Handler.dispatchMessage(Handler.java:102)\r\n[ERROR] : TiApplication: \tat android.os.Looper.loop(Looper.java:148)\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread.main(ActivityThread.java:5466)\r\n[ERROR] : TiApplication: \tat java.lang.reflect.Method.invoke(Native Method)\r\n[ERROR] : TiApplication: \tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)\r\n[ERROR] : TiApplication: \tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)\r\n[ERROR] : TiApplication: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference\r\n[ERROR] : TiApplication: \tat org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)\r\n[ERROR] : TiApplication: \tat org.json.JSONTokener.nextValue(JSONTokener.java:94)\r\n[ERROR] : TiApplication: \tat org.json.JSONObject.(JSONObject.java:156)\r\n[ERROR] : TiApplication: \tat org.json.JSONObject.(JSONObject.java:173)\r\n[ERROR] : TiApplication: \tat com.appcelerator.aps.APSCloudPush.showTrayNotification(APSCloudPush.java:347)\r\n[ERROR] : TiApplication: \tat com.appcelerator.aps.APSCloudPush.receivePayload(APSCloudPush.java:253)\r\n[ERROR] : TiApplication: \tat com.appcelerator.aps.GCMReceiver.onReceive(GCMReceiver.java:30)\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread.handleReceiver(ActivityThread.java:2769)\r\n[ERROR] : TiApplication: \t... 8 more\r\n{code}\r\n\r\nh6.Information\r\nwe tried the following structure for sending notifications:\r\n\r\nSuggested By Appcelerator but not working\r\n{code} \r\n\"data\":{\r\n \"payload\":{\r\n \"android\": {\r\n \"alert\": \"This is a message from my own server\"\r\n }\r\n }\r\n}\r\n{code} \r\n\r\nh6.AWS DEFAULT BUT NOT WORKING:\r\n \r\n{code}\r\n{\r\n\"default\": \"Welcome\",\r\n\"GCM\": \"{ \\\"data\\\": { \\\"message\\\": \\\"Welcome\\\" } }\"\r\n}\r\n{code}\r\n \r\nh6.WORKING ONE\r\nBut when we tried this, if app is in foreground it shows the message, but in background it crashes again :\r\n{code}\r\n{\r\n\"default\": \"Welcome\",\r\n\"GCM\": \"{ \\\"data\\\": { \\\"payload\\\": \\\"Welcome\\\" } }\"\r\n}\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: Push Notification Payload Null", "creator": { "name": "swapn1l", "key": "swapn1l", "displayName": "Swapnil Singh", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "swapn1l", "key": "swapn1l", "displayName": "Swapnil Singh", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK 5.1.2.GA and 5.2.0v20151125112632\r\nAndroid 5", "comment": { "comments": [ { "id": "375486", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Hi [~swapn1l] can you provide a runnable test case and state what device model/OS reproduces this on please? ", "updateAuthor": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-01-29T03:14:54.000+0000", "updated": "2016-01-29T03:15:16.000+0000" }, { "id": "376248", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "body": "h6.Sample app.js\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n layout: 'vertical',\r\n backgroundColor: 'white'\r\n});\r\n\r\nvar CloudPush = require('ti.cloudpush');\r\n\r\nvar code = CloudPush.isGooglePlayServicesAvailable();\r\nif (code != CloudPush.SUCCESS) {\r\n alert (\"Google Play Services is not installed/updated/available\");\r\n}\r\n\r\nCloudPush.addEventListener('callback', function (evt) {\r\n alert(evt.payload);\r\n});\r\nCloudPush.addEventListener('trayClickLaunchedApp', function (evt) {\r\n Ti.API.info('Tray Click Launched App (app was not running)');\r\n});\r\nCloudPush.addEventListener('trayClickFocusedApp', function (evt) {\r\n Ti.API.info('Tray Click Focused App (app was already running)');\r\n});\r\n\r\n/*\r\n * Create a label to show Push type\r\n */\r\nvar pushTypeLabel = Ti.UI.createLabel({\r\n top: '10dp', width: '320dp', height: '25dp',\r\n textAlign: 'center', font: { fontSize:14}, color: 'black',\r\n text: 'Push Type: ' + CloudPush.pushType\r\n});\r\nwin.add(pushTypeLabel);\r\n\r\n/*\r\n * Create a label to show device token on screen\r\n */\r\nvar deviceTokenLabel = Ti.UI.createLabel({\r\n top: '10dp', width: '320dp', height: (CloudPush.pushType=='gcm'?'150dp':'40dp'),\r\n font: { fontSize:14}, color: 'black',\r\n text: 'Device Token'\r\n});\r\nwin.add(deviceTokenLabel);\r\n\r\nCloudPush.retrieveDeviceToken({\r\n success: deviceTokenSuccess,\r\n error: deviceTokenError\r\n});\r\n\r\nfunction deviceTokenSuccess(e) {\r\n Ti.API.info('Device Token: ' + e.deviceToken);\r\n deviceTokenLabel.text = 'Device Token:' + e.deviceToken;\r\n enablePush.enabled = true;\r\n}\r\n\r\nfunction deviceTokenError(e) {\r\n alert('Failed to register for push! ' + e.error);\r\n deviceTokenLabel.text = 'Failed to get device token.';\r\n}\r\n\r\n/*\r\n Push can be enabled or disabled.\r\n */\r\nvar enablePush = Ti.UI.createButton({\r\n top: '10dp', width: '320dp', height: '40dp',\r\n enabled: false\r\n});\r\nenablePush.addEventListener('click', function () {\r\n enablePush.title = CloudPush.enabled ? 'Disabling...' : 'Enabling...';\r\n CloudPush.enabled = !CloudPush.enabled;\r\n // NOTE: Push.enabled takes a moment to update after you change its value.\r\n setTimeout(syncButtons, 500);\r\n});\r\nwin.add(enablePush);\r\n\r\n/*\r\n Whether or not to show a tray notification.\r\n */\r\nvar showTrayNotification = Ti.UI.createButton({\r\n top: '10dp', width: '320dp', height: '40dp'\r\n});\r\nshowTrayNotification.addEventListener('click', function () {\r\n CloudPush.showTrayNotification = !CloudPush.showTrayNotification;\r\n syncButtons();\r\n});\r\nwin.add(showTrayNotification);\r\n\r\n/*\r\n Whether or not clicking a tray notification focuses the app.\r\n */\r\nvar showAppOnTrayClick = Ti.UI.createButton({\r\n top: '10dp', width: '320dp', height: '40dp'\r\n});\r\nshowAppOnTrayClick.addEventListener('click', function () {\r\n CloudPush.showAppOnTrayClick = !CloudPush.showAppOnTrayClick;\r\n syncButtons();\r\n});\r\nwin.add(showAppOnTrayClick);\r\n\r\n/*\r\n Whether or not tray notifications are shown when the app is in the foreground.\r\n */\r\nvar showTrayNotificationsWhenFocused = Ti.UI.createButton({\r\n top: '10dp', width: '320dp', height: '40dp'\r\n});\r\nshowTrayNotificationsWhenFocused.addEventListener('click', function () {\r\n CloudPush.showTrayNotificationsWhenFocused = !CloudPush.showTrayNotificationsWhenFocused;\r\n syncButtons();\r\n});\r\nwin.add(showTrayNotificationsWhenFocused);\r\n\r\n/*\r\n Whether or not receiving a push immediately brings the application to the foreground.\r\n */\r\nvar focusAppOnPush = Ti.UI.createButton({\r\n top: '10dp', width: '320dp', height: '40dp'\r\n});\r\nfocusAppOnPush.addEventListener('click', function () {\r\n CloudPush.focusAppOnPush = !CloudPush.focusAppOnPush;\r\n syncButtons();\r\n});\r\nwin.add(focusAppOnPush);\r\n\r\n/*\r\n Trigger callbacks together or one by one when multiple push notifications come.\r\n */\r\nvar singleCallback = Ti.UI.createButton({\r\n top: '10dp', width: '320dp', height: '40dp'\r\n});\r\nsingleCallback.addEventListener('click', function () {\r\n CloudPush.singleCallback = !CloudPush.singleCallback;\r\n syncButtons();\r\n});\r\nwin.add(singleCallback);\r\n\r\nfunction syncButtons() {\r\n enablePush.title = CloudPush.enabled ? 'Push Enabled' : 'Push Disabled';\r\n showAppOnTrayClick.title = CloudPush.showAppOnTrayClick ? 'Tray Click Shows App' : 'Tray Click Does Nothing';\r\n showTrayNotification.title = CloudPush.showTrayNotification ? 'Show in Tray' : 'Do Not Show in Tray';\r\n focusAppOnPush.title = CloudPush.focusAppOnPush ? 'Push Focuses App' : 'Push Doesn\\'t Focus App';\r\n showTrayNotificationsWhenFocused.title = CloudPush.showTrayNotificationsWhenFocused ? 'Show Trays when Focused' : 'Hide Trays when Focused';\r\n singleCallback.title = CloudPush.singleCallback ? 'Callbacks trigger one by one' : 'Callbacks trigger together';\r\n}\r\n\r\nsyncButtons();\r\nwin.open();\r\n{code}", "updateAuthor": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2016-02-08T18:13:20.000+0000", "updated": "2016-02-08T18:13:20.000+0000" }, { "id": "376307", "author": { "name": "ncook", "key": "ncook", "displayName": "Nathan Cook", "active": true, "timeZone": "Europe/London" }, "body": "I've tested for this using my push notification app and I'm not running into any issues, I've tried with app closed, background and foreground, and after getting the push notification I run into no issues opening the app. Tested it on studio 5.1.2GA and 5.2.0v20160208101502, on android 5.1.1 and 6. Do you have any other information on it?", "updateAuthor": { "name": "ncook", "key": "ncook", "displayName": "Nathan Cook", "active": true, "timeZone": "Europe/London" }, "created": "2016-02-09T01:14:09.000+0000", "updated": "2016-02-09T01:14:09.000+0000" }, { "id": "378255", "author": { "name": "annakozy@direcciona.me", "key": "annakozy@direcciona.me", "displayName": "Ganna Kozynenko", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I am running into this crash when sending messages from another push provider (Parse). I am asked to keep parse while integrating other push notifications system, so when I send the message from Parse and it's received by CloudPush, it crashes! \r\nIn this scenario, payload IS null by design. \r\n\r\nCrash is observed when app was in background, but it is sufficient to render the module unusable in any scenario where pushes come not only from ACS, but from other sources\r\n\r\nSDK : 5.1.2.GA\r\nAndroid : 5.1.1\r\nTi.Cloudpush version: 3.4.1", "updateAuthor": { "name": "annakozy@direcciona.me", "key": "annakozy@direcciona.me", "displayName": "Ganna Kozynenko", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-03-01T09:28:42.000+0000", "updated": "2016-03-01T11:15:50.000+0000" }, { "id": "391403", "author": { "name": "arildo", "key": "arildo", "displayName": "Arildo Junior", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I'm also using an alternative push provider. To make it work you need to send the payload exactly how the CloudPush docs require. In my case:\r\n\r\n{\"GCM\": \"{ \\\"data\\\": { \\\"payload\\\": { \\\"android\\\": { \\\"alert\\\": \\\"text notification\\\",\\\"icon\\\": \\\"appicon\\\" } }} }\"}\r\n\r\nFor me it's solved sending like this.\r\n\r\nHope it helps.", "updateAuthor": { "name": "arildo", "key": "arildo", "displayName": "Arildo Junior", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-07-25T09:51:52.000+0000", "updated": "2016-07-25T09:51:52.000+0000" }, { "id": "451942", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "As mentioned in previous comment cloudpush is meant to be used with arrow backend & not guranteed to work with other backends like aws.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-10-09T21:19:02.000+0000", "updated": "2019-10-10T22:37:55.000+0000" }, { "id": "452741", "author": { "name": "ahutton", "key": "ahutton", "displayName": "Alan Hutton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing per dev comments. \"cloudpush is meant to be used with arrow backend & not guranteed to work with other backends like aws\"", "updateAuthor": { "name": "ahutton", "key": "ahutton", "displayName": "Alan Hutton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-11-15T22:30:15.000+0000", "updated": "2019-11-15T22:30:15.000+0000" } ], "maxResults": 13, "total": 13, "startAt": 0 } } }