{ "id": "154610", "key": "AC-591", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "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-02-07T05:52:31.000+0000", "created": "2016-02-01T10:14:42.000+0000", "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2016-02-07T05:52:31.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": [], "description": "Hello,\r\n\r\nUsing Ti.cloudpush module i m able to retrieve devicetoken on android,\r\n\r\nbut sometimes the devicetoken returned is null,\r\nwhen i re-install the app, it successfully returns a devicetoken", "attachment": [], "flagged": false, "summary": "DeviceToken null on Android", "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": "CLI : Latest\r\nStudio : Latest\r\nSDK : 5.2.0 v20151125112632\r\n\r\n", "comment": { "comments": [ { "id": "375702", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "In which device you are trying? Try the below code\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor : '#ccc',\r\n title : 'Android Cloud Push Notification'\r\n});\r\n\r\nvar CloudPush = require('ti.cloudpush');\r\nCloudPush.debug = true;\r\nCloudPush.enabled = true;\r\nCloudPush.showTrayNotificationsWhenFocused = true;\r\nCloudPush.showTrayNotification = true;\r\nCloudPush.focusAppOnPush = false;\r\n\r\nvar deviceToken = null;\r\nvar Cloud = require('ti.cloud');\r\nCloud.debug = true;\r\n\r\nvar submit = Ti.UI.createButton({\r\n title : 'Register For Push Notification',\r\n color : '#000',\r\n height : 60,\r\n width : 200,\r\n top : 100,\r\n});\r\n\r\nwin.add(submit);\r\n\r\nsubmit.addEventListener('click', function(e) {\r\n loginDefault();\r\n});\r\n\r\nvar submit1 = Ti.UI.createButton({\r\n title : 'Subscribe Device',\r\n color : '#000',\r\n height : 60,\r\n width : 200,\r\n top : 200,\r\n});\r\n\r\nwin.add(submit1);\r\n\r\nsubmit1.addEventListener('click', function(e) {\r\n defaultSubscribe();\r\n});\r\n\r\nvar submit2 = Ti.UI.createButton({\r\n title : 'Unsubscribe Device',\r\n color : '#000',\r\n height : 60,\r\n width : 200,\r\n top : 300,\r\n});\r\n\r\nwin.add(submit2);\r\n\r\nsubmit2.addEventListener('click', function(e) {\r\n defaultUnSubscribe();\r\n});\r\n\r\nCloudPush.retrieveDeviceToken({\r\n success : deviceTokenSuccess,\r\n error : deviceTokenError\r\n});\r\n\r\nfunction deviceTokenSuccess(e) {\r\n deviceToken = e.deviceToken;\r\n}\r\n\r\nfunction deviceTokenError(e) {\r\n alert('Failed to register for push notifications! ' + e.error);\r\n}\r\n\r\nCloudPush.addEventListener('callback', function(evt) {\r\n alert(\"Notification received: \" + evt.payload);\r\n});\r\n\r\nCloudPush.addEventListener('trayClickLaunchedApp', function(evt) {\r\n Ti.API.info('Tray Click Launched App (app was not running)');\r\n});\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\nfunction loginDefault(e) {\r\n Cloud.Users.login({\r\n login : 'User Email',\r\n password : 'Pass'\r\n }, function(e) {\r\n if (e.success) {\r\n alert(\"Successfully Loged In\");\r\n } else {\r\n alert('Error: ' + ((e.error && e.message) || JSON.stringify(e)));\r\n }\r\n });\r\n}\r\n\r\nfunction defaultSubscribe() {\r\n Cloud.PushNotifications.subscribe({\r\n channel : 'alert',\r\n device_token : deviceToken,\r\n type : 'android'\r\n }, function(e) {\r\n if (e.success) {\r\n alert('Device Subscribed!');\r\n } else {\r\n alert('Error:' + ((e.error && e.message) || JSON.stringify(e)));\r\n }\r\n });\r\n}\r\n\r\nfunction defaultUnSubscribe() {\r\n Cloud.PushNotifications.unsubscribe({\r\n channel : 'alert',\r\n device_token : deviceToken,\r\n type : 'android'\r\n }, function(e) {\r\n if (e.success) {\r\n alert('Device Unsubscribed!');\r\n } else {\r\n alert('Error:\\n' + ((e.error && e.message) || JSON.stringify(e)));\r\n }\r\n });\r\n}\r\n\r\nwin.open(); \r\n{code}\r\n\r\nThe code is self-explanatory. Create a user in your arrowDB in the platform and provide the email and pass in loginDefault(). First login and then subscribe the device and send push notification. Thanks.\r\n", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2016-02-02T07:45:00.000+0000", "updated": "2016-02-02T07:45:00.000+0000" }, { "id": "375726", "author": { "name": "swapn1l", "key": "swapn1l", "displayName": "Swapnil Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The code applied is same as mentioned in Appcelerator Documentation:\r\n\r\n// Require the module\r\nvar CloudPush = require('ti.cloudpush');\r\nvar deviceToken = null;\r\n\r\n// Initialize the module\r\nCloudPush.retrieveDeviceToken({\r\n\tsuccess : deviceTokenSuccess,\r\n\terror : deviceTokenError\r\n});\r\n// Enable push notifications for this device\r\n// Save the device token for subsequent API calls\r\nfunction deviceTokenSuccess(e) {\r\n\tdeviceToken = e.deviceToken;\r\n\t//alert(deviceToken);\r\n}\r\n\r\nfunction deviceTokenError(e) {\r\n\t//alert('Failed to register for push notifications! ' + e.error);\r\n}\r\n\r\n// Process incoming push notifications\r\nCloudPush.addEventListener('callback', function(evt) {\r\n\tTi.API.info(\"NOTIFICATION :\" + JSON.stringify(evt));\r\n});\r\n\r\n\r\nAnd we r using AWS SNS for sending push notifications to the device", "updateAuthor": { "name": "swapn1l", "key": "swapn1l", "displayName": "Swapnil Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-02-02T13:38:17.000+0000", "updated": "2016-02-02T13:38:17.000+0000" }, { "id": "375828", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "What device you are generating the issue. Give us the model number. Also, make sure you use ti.cloudpush 3.4.1 module version. ", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2016-02-03T05:37:33.000+0000", "updated": "2016-02-03T05:39:10.000+0000" }, { "id": "375841", "author": { "name": "swapn1l", "key": "swapn1l", "displayName": "Swapnil Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I see to the ti.cloudpush version,\r\n\r\nwhereas i have been facing this issue on Motorola G3 series phones for now", "updateAuthor": { "name": "swapn1l", "key": "swapn1l", "displayName": "Swapnil Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-02-03T08:16:10.000+0000", "updated": "2016-02-03T08:16:10.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }