{ "id": "165372", "key": "AC-4744", "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": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-02-01T20:32:12.000+0000", "created": "2017-01-19T11:21:25.000+0000", "labels": [], "versions": [ { "id": "17038", "name": "Appcelerator Studio 4.5.0", "archived": false, "released": false } ], "issuelinks": [], "assignee": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2017-02-01T20:32:13.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": "14550", "name": "Appcelerator Modules", "description": "Please enter tickets related to Modules here." }, { "id": "14560", "name": "Arrow Push" }, { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "We implemented Android push in application but having one small issue.\r\n\r\nWhen application is running/foreground/active it is not calling callback function. \r\n\r\nIn debug window we can see this when new message came.\r\n\r\n[INFO] : APSCloudPush: receivePayload: {\"android\":{\"badge\":\"0\",\"alert\":\"New message(s) received\",\"sound\":\"default\",\"icon\":\"icon\",\"vibrate\":true,\"title\":\"CareChatZ\"}}\r\n\r\n[INFO] : APSCloudPush: background: true\r\n\r\n[INFO] : APSCloudPush: processCallbackIfInstantiated payload: {\"android\":{\"badge\":\"0\",\"alert\":\"New message(s) \r\nreceived\",\"sound\":\"default\",\"icon\":\"icon\",\"vibrate\":true,\"title\":\"CareChatZ\"}}\r\n\r\n\r\nPlease help", "attachment": [], "flagged": false, "summary": "cloudpush not calling callback when application is running - forground", "creator": { "name": "anisvora", "key": "anisvora", "displayName": "Anis Vora", "active": true, "timeZone": "Asia/Kolkata" }, "subtasks": [], "reporter": { "name": "anisvora", "key": "anisvora", "displayName": "Anis Vora", "active": true, "timeZone": "Asia/Kolkata" }, "environment": "5.4.0.GA , TI.cloudpush 3.4.1 (*)", "comment": { "comments": [ { "id": "404860", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Send the sample code that regenerates the issue. Also, Use the latest SDK 6.0.1.GA for your build. ", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-01-19T14:53:07.000+0000", "updated": "2017-01-19T14:53:07.000+0000" }, { "id": "404920", "author": { "name": "anisvora", "key": "anisvora", "displayName": "Anis Vora", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Hello,\r\n\r\nThanks for prompt reply , can't switch to 6.0.1 GA as we are using titutorial.audiorecorder module and it is not compatible with that.\r\n\r\nNow about code , it is all same as http://docs.appcelerator.com/platform/latest/#!/api/Modules.CloudPush\r\n\r\n{noformat}\r\n\r\nif(isAndroid)\r\n{\r\n\tCloudPush = require('ti.cloudpush');\r\n CloudPush.showTrayNotificationsWhenFocused = false;\r\n CloudPush.showAppOnTrayClick = true;\r\n CloudPush.showTrayNotification = true;\r\n CloudPush.debug = true;\r\n} \r\n\r\nCloudPush.addEventListener('callback', function (evt) {\r\n alert(evt.payload);\r\n});\r\n\r\n{noformat}\r\n\r\n\r\nI also checked Androidmanifest.xml file from build directory and all seems to be good.\r\n\r\nThanks in advance.\r\n\r\nRegards,\r\nAnis", "updateAuthor": { "name": "anisvora", "key": "anisvora", "displayName": "Anis Vora", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2017-01-20T11:41:48.000+0000", "updated": "2017-01-20T11:44:07.000+0000" }, { "id": "404939", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, I just checked. callback is called successfully as alert, when App is running in foreground.I am running in Android 6.0.1. with SDK 6.0.1.GA. Use the below code.\r\n{code}\r\nCloudPush.showTrayNotificationsWhenFocused = true;\r\n{code}\r\nThanks.\r\n\r\n ", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-01-20T16:42:29.000+0000", "updated": "2017-01-20T16:43:30.000+0000" }, { "id": "405024", "author": { "name": "anisvora", "key": "anisvora", "displayName": "Anis Vora", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Hello,\r\n\r\nThanks for your reply.\r\n\r\nToday we found interesting thing , that CloudPush variable was part of config.js which have all common functions and variables and that is getting included in all page off application.\r\n\r\nNow today we move that CloudPush variable and event listener to app.js and .... bingo .. it start working , but with small problem it works only in first screen of application which is getting called from app.js .. so if we move to other screen in app it is not calling that callback event.\r\n\r\nDo you have any idea on that ?\r\n\r\nRegard,\r\nAnis", "updateAuthor": { "name": "anisvora", "key": "anisvora", "displayName": "Anis Vora", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2017-01-21T12:14:14.000+0000", "updated": "2017-01-21T12:14:14.000+0000" }, { "id": "405096", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Can you share a sample project that we can use to reproduce the issue? We will investigate it. ", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-01-23T19:46:17.000+0000", "updated": "2017-01-23T19:46:17.000+0000" }, { "id": "405163", "author": { "name": "anisvora", "key": "anisvora", "displayName": "Anis Vora", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Hello,\r\n\r\nThanks you very much for all your continues support. \r\n\r\nI sent you sample code and all required details , please let me know if anything more is require.\r\n\r\nRegards,\r\nAnis", "updateAuthor": { "name": "anisvora", "key": "anisvora", "displayName": "Anis Vora", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2017-01-24T11:39:51.000+0000", "updated": "2017-01-24T11:39:51.000+0000" }, { "id": "405204", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, Your sample app has lots of issue like ti.include, which is deprecated. I made a sample app myself which is working as expected. See my sample app.\r\napp.js\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\n CloudPush.debug = true;\r\n CloudPush.enabled = true;\r\n CloudPush.showTrayNotificationsWhenFocused = true;\r\n CloudPush.showTrayNotification = true;\r\n CloudPush.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\nvar submit3 = Ti.UI.createButton({\r\n title : 'New Window',\r\n color : '#000',\r\n height : 60,\r\n width : 200,\r\n top : 400,\r\n});\r\n \r\nwin.add(submit3);\r\n \r\nsubmit3.addEventListener('click', function(e) {\r\n var NewWin = require(\"NewWindow\");\r\n var self = NewWin();\r\n});\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 : 'shajib.sigma@gmail.com',\r\n password : '123456'\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\nNewWindow.js\r\n{code}\r\nfunction NewWindow() {\r\n var self = Ti.UI.createWindow({\r\n backgroundColor : '#ffffff',\r\n navBarHidden : true,\r\n fullscreen : true,\r\n //width : '100%'\r\n\r\n });\r\n var button = Ti.UI.createButton({\r\n width : 100,\r\n height : 100,\r\n top: 0,\r\n title: 'Back'\r\n\r\n });\r\n \r\n button.addEventListener('click', function(e){\r\n self.close();\r\n \r\n });\r\n \r\n self.add(button);\r\n self.open();\r\n\r\n}\r\n\r\nmodule.exports = NewWindow; \r\n{code}\r\nFirst use the above code in a new project. Create a new user in the arrowDB console in platform and provide the email and pass in the above code. As\r\n{code}\r\nCloud.Users.login({\r\n login : 'xxxxxx@gmail.com',\r\n password : '123456'\r\n }\r\n{code}\r\n\r\nConfigure firebase push notification for the app in the console. \r\nClick register for push notification for login(see the success alert)\r\nClick subscribe device for device subscription(see the success alert)\r\nClick New window to open another window. \r\nSend push notification from the console.\r\nSee the alert open as the push received and whole lot.\r\n\r\nThanks.\r\n\r\n", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-01-24T19:02:18.000+0000", "updated": "2017-01-24T19:02:18.000+0000" }, { "id": "405473", "author": { "name": "anisvora", "key": "anisvora", "displayName": "Anis Vora", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Hello Sharif,\r\n\r\nReally thanks for all your help and time you spent to help us.\r\n\r\nFinally we found the problem , it was because of win.close .. like as part of good practice we are closing previous win once new window get loaded.\r\n\r\nSo, it works fine in first screen which is loaded from app , and if we move to other screen then that win is getting closed and callback stops working.\r\n\r\nNow , one small problem .. that push notification icon in notification tray is plain white square instead of actual logo/icon. Can you help with that ? or do we need to write in other post ?\r\n\r\nRegards,\r\nAnis", "updateAuthor": { "name": "anisvora", "key": "anisvora", "displayName": "Anis Vora", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2017-01-27T09:45:25.000+0000", "updated": "2017-01-27T09:45:25.000+0000" }, { "id": "405890", "author": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "body": "Hello, You need to put a custom icon in project \"platform/android/res/drawable\" directory. This icon will be used to show notification bar and be used as icon of notification item in the notification center. provide the name of the file without the extinction in icon field when you send the push notification from platform. If the field is empty default icon will be used. See guide: http://docs.appcelerator.com/platform/latest/#!/guide/Sending_and_Scheduling_Push_Notifications Android-specific payload fields/icon.", "updateAuthor": { "name": "sdarda", "key": "sdarda", "displayName": "Sharif AbuDarda", "active": false, "timeZone": "Asia/Dhaka" }, "created": "2017-01-31T19:30:31.000+0000", "updated": "2017-01-31T19:37:09.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }