{ "id": "138092", "key": "AC-1644", "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": "2015-08-28T03:21:44.000+0000", "created": "2014-10-15T10:33:48.000+0000", "labels": [ "TCSupportTriage" ], "versions": [], "issuelinks": [], "assignee": { "name": "mrahman", "key": "mrahman", "displayName": "Mostafizur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "updated": "2016-03-08T07:38:07.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "h3. Steps to Reproduce\n- Run application on device\n- enbale pussh notification by subscribing to channel\n- send push notification from server backend using appcelerator's API\n- mobile application will display force close\n\nh3. Actual Result\napplication force close and error is displayed in the studio's console\n\nh3. Expected Result\napplication does not force close and push notification arrives to device and is displayed in the notification tray", "attachment": [ { "id": "51983", "filename": ".log", "author": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "created": "2014-10-15T10:33:51.000+0000", "size": 532202, "mimeType": "text/plain" }, { "id": "51984", "filename": "diagnostic7631614009080662813.log", "author": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "created": "2014-10-15T10:34:09.000+0000", "size": 45998, "mimeType": "text/plain" } ], "flagged": false, "summary": "Push Notification on Android devices are not arriving and cause a Force Close", "creator": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "subtasks": [], "reporter": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "environment": "Titanium Studio 3.3.0", "comment": { "comments": [ { "id": "328156", "author": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "body": "error from the studio's console\r\n{code}\r\n[WARN] : dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x4161cba8)\r\n[ERROR] : TiApplication: (main) [74332,74332] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start receiver com.appcelerator.cloudpush.GCMReceiver: java.lang.NullPointerException; Titanium 3.3.0,2014/07/11 12:36,787cd39\r\n[ERROR] : TiApplication: java.lang.RuntimeException: Unable to start receiver com.appcelerator.cloudpush.GCMReceiver: java.lang.NullPointerException\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread.handleReceiver(ActivityThread.java:2414)\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread.access$1700(ActivityThread.java:135)\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)\r\n[ERROR] : TiApplication: \tat android.os.Handler.dispatchMessage(Handler.java:102)\r\n[ERROR] : TiApplication: \tat android.os.Looper.loop(Looper.java:136)\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread.main(ActivityThread.java:5001)\r\n[ERROR] : TiApplication: \tat java.lang.reflect.Method.invokeNative(Native Method)\r\n[ERROR] : TiApplication: \tat java.lang.reflect.Method.invoke(Method.java:515)\r\n[ERROR] : TiApplication: \tat com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)\r\n[ERROR] : TiApplication: \tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)\r\n[ERROR] : TiApplication: \tat dalvik.system.NativeStart.main(Native Method)\r\n[ERROR] : TiApplication: Caused by: java.lang.NullPointerException\r\n[ERROR] : TiApplication: \tat com.appcelerator.cloudpush.utils.APSProperties.(APSProperties.java:45)\r\n[ERROR] : TiApplication: \tat com.appcelerator.cloudpush.Settings.props(Settings.java:45)\r\n[ERROR] : TiApplication: \tat com.appcelerator.cloudpush.Settings.useSingleCallback(Settings.java:67)\r\n[ERROR] : TiApplication: \tat com.appcelerator.cloudpush.APSCloudPush.receivePayload(APSCloudPush.java:229)\r\n[ERROR] : TiApplication: \tat com.appcelerator.cloudpush.GCMReceiver.onReceive(GCMReceiver.java:31)\r\n[ERROR] : TiApplication: \tat android.app.ActivityThread.handleReceiver(ActivityThread.java:2407)\r\n[ERROR] : TiApplication: \t... 10 more\r\n[INFO] : Process: Sending signal. PID: 6241 SIG: 9\r\n{code}", "updateAuthor": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "created": "2014-10-15T10:35:58.000+0000", "updated": "2014-10-15T10:35:58.000+0000" }, { "id": "328290", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Hi,\r\n\r\nWould you please provider us a test case to reproduce your problem. That will be really helpful. Thanks.\r\n\r\nRegards,\r\nShuo", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2014-10-16T04:05:07.000+0000", "updated": "2014-10-16T04:05:07.000+0000" }, { "id": "328298", "author": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "body": "Hey,\r\n\r\nI can gladly share code for the titanium part and the wordpress plugin that is calling the notify in order to send push notifications....let me know what is most helpful to you.\r\n\r\nRegards,\r\nFouad", "updateAuthor": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "created": "2014-10-16T07:37:41.000+0000", "updated": "2014-10-16T07:37:41.000+0000" }, { "id": "328299", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Maybe the part of titanium that received push notification.", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2014-10-16T07:42:25.000+0000", "updated": "2014-10-16T07:42:25.000+0000" }, { "id": "328301", "author": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "body": "{code}\r\nfunction TableMenu(parentWindow) {\r\n\tvar Cloud = require('ti.cloud');\r\n\tvar osname = Ti.Platform.osname;\r\n\tvar deviceTokenKey = 'deviceToken';\r\n\tvar pnEnabledKey = 'pnEnabled';\r\n\tvar firstBootKey = 'firstBoot';\r\n\tvar pnChannel = 'news';\r\n\tvar switchButton = Ti.UI.createSwitch();\r\n\r\n\tfunction retrieveDeviceToken(cb) {\r\n\t\t// Enable push notifications for this device\r\n\t\t// Save the device token for subsequent API calls\r\n\t\tfunction deviceTokenSuccess(e) {\r\n\t\t\tTi.API.info('successfully got device token');\r\n\t\t\tTi.App.Properties.setString(deviceTokenKey, e.deviceToken);\r\n\t\t\tcb(null);\r\n\t\t}\r\n\r\n\t\tfunction deviceTokenError(e) {\r\n\t\t\tTi.API.error('Failed to register for push notifications! ' + e.error);\r\n\t\t\tTi.App.Properties.setString(deviceTokenKey, '');\r\n\t\t\tcb(e.error);\r\n\t\t}\r\n\r\n\t\tif (osname === 'android') {\r\n\t\t\tvar CloudPush = require('ti.cloudpush');\r\n\t\t\tCloudPush.debug = true;\r\n\t\t\tCloudPush.enabled = true;\r\n\r\n\t\t\t// Initialize the module\r\n\t\t\tCloudPush.retrieveDeviceToken({\r\n\t\t\t\tsuccess : deviceTokenSuccess,\r\n\t\t\t\terror : deviceTokenError\r\n\t\t\t});\r\n\r\n\t\t\t// Process incoming push notifications\r\n\t\t\tCloudPush.addEventListener('callback', function(evt) {\r\n\t\t\t\tTi.API.info(\"Notification received: \" + evt.payload);\r\n\t\t\t\tvar payload = JSON.parse(evt.payload);\r\n\t\t\t\thandlePushNotificationMessages(payload);\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\t// Process incoming push notifications\r\n\t\t\tfunction receivePush(e) {\r\n\t\t\t\tTi.API.info('Received push: ' + JSON.stringify(e));\r\n\t\t\t\tvar payload = e.data;\r\n\t\t\t\thandlePushNotificationMessages(payload);\r\n\t\t\t}\r\n\r\n\t\t\t// Check if the device is running iOS 8 or later\r\n\t\t\tif (Ti.Platform.name == \"iPhone OS\" && parseInt(Ti.Platform.version.split(\".\")[0]) >= 8) {\r\n\t\t\t\tfunction registerForPush() {\r\n\t\t\t\t\tTi.Network.registerForPushNotifications({\r\n\t\t\t\t\t\tsuccess : deviceTokenSuccess,\r\n\t\t\t\t\t\terror : deviceTokenError,\r\n\t\t\t\t\t\tcallback : receivePush\r\n\t\t\t\t\t});\r\n\t\t\t\t\t// Remove event listener once registered for push notifications\r\n\t\t\t\t\tTi.App.iOS.removeEventListener('usernotificationsettings', registerForPush);\r\n\t\t\t\t};\r\n\r\n\t\t\t\t// Wait for user settings to be registered before registering for push notifications\r\n\t\t\t\tTi.App.iOS.addEventListener('usernotificationsettings', registerForPush);\r\n\r\n\t\t\t\t// Register notification types to use\r\n\t\t\t\tTi.App.iOS.registerUserNotificationSettings({\r\n\t\t\t\t\ttypes : [Ti.App.iOS.USER_NOTIFICATION_TYPE_ALERT, Ti.App.iOS.USER_NOTIFICATION_TYPE_SOUND, Ti.App.iOS.USER_NOTIFICATION_TYPE_BADGE]\r\n\t\t\t\t});\r\n\r\n\t\t\t} else {\r\n\t\t\t\t// For iOS 7 and earlier\r\n\t\t\t\tTi.Network.registerForPushNotifications({\r\n\t\t\t\t\t// Specifies which notifications to receive\r\n\t\t\t\t\ttypes : [Ti.Network.NOTIFICATION_TYPE_BADGE, Ti.Network.NOTIFICATION_TYPE_ALERT, Ti.Network.NOTIFICATION_TYPE_SOUND],\r\n\t\t\t\t\tsuccess : deviceTokenSuccess,\r\n\t\t\t\t\terror : deviceTokenError,\r\n\t\t\t\t\tcallback : receivePush\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction subscribeToChannel() {\r\n\t\t// Subscribes the device to the 'news_alerts' channel\r\n\t\t// Specify the push type as either 'android' for Android or 'ios' for iOS\r\n\t\tCloud.PushNotifications.subscribeToken({\r\n\t\t\tdevice_token : Ti.App.Properties.getString(deviceTokenKey, ''),\r\n\t\t\tchannel : pnChannel,\r\n\t\t\ttype : Ti.Platform.name == 'android' ? 'android' : 'ios'\r\n\t\t}, function(e) {\r\n\t\t\tif (e.success) {\r\n\t\t\t\tTi.API.info('Subscribed to channel');\r\n\t\t\t\tTi.App.Properties.setBool(pnEnabledKey, true);\r\n\t\t\t\tswitchButton.value = true;\r\n\t\t\t} else {\r\n\t\t\t\tTi.API.error('Error: ' + ((e.error && e.message) || JSON.stringify(e)));\r\n\t\t\t\tTi.App.Properties.setBool(pnEnabledKey, false);\r\n\t\t\t\tswitchButton.value = false;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tfunction unsubscribeToChannel() {\r\n\t\t// Unsubscribes the device from the 'test' channel\r\n\t\tCloud.PushNotifications.unsubscribeToken({\r\n\t\t\tdevice_token : Ti.App.Properties.getString(deviceTokenKey, ''),\r\n\t\t\tchannel : pnChannel,\r\n\t\t}, function(e) {\r\n\t\t\tif (e.success) {\r\n\t\t\t\tTi.API.info('Unsubscribed from channel');\r\n\t\t\t\tTi.App.Properties.setBool(pnEnabledKey, false);\r\n\t\t\t\tswitchButton.value = false;\r\n\t\t\t} else {\r\n\t\t\t\tTi.API.error('Error: ' + ((e.error && e.message) || JSON.stringify(e)));\r\n\t\t\t\tTi.App.Properties.setBool(pnEnabledKey, true);\r\n\t\t\t\tswitchButton.value = true;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tfunction handlePushNotificationMessages(payload) {\r\n\t\tvar newsObj = {\r\n\t\t\ttitle : payload.postTitle,\r\n\t\t\tlink : payload.postUrl,\r\n\t\t\tdate : payload.postDate,\r\n\t\t\ttime : payload.postTime,\r\n\t\t\tpubDate : '',\r\n\t\t\tdescription : '',\r\n\t\t\timage : ''\r\n\t\t};\r\n\t\tnewsObj.pushNotificationNews = true;\r\n\r\n\t\tvar DetailView = require('ui/common/DetailView');\r\n\t\tvar detailView = new DetailView(newsObj, true);\r\n\t\tif (parentWindow) {\r\n\t\t\tvar currentBadge = Ti.UI.iPhone.getAppBadge();\r\n\t\t\tif (currentBadge > 0) {\r\n\t\t\t\tcurrentBadge = currentBadge - 1;\r\n\t\t\t\tTi.UI.iPhone.setAppBadge(currentBadge);\r\n\t\t\t}\r\n\t\t\tif (parentWindow.isLeftWindowOpen()) {\r\n\t\t\t\tparentWindow.toggleLeftWindow();\r\n\t\t\t}\r\n\t\t\tparentWindow.getCenterWindow().openWindow(detailView, {\r\n\t\t\t\t//this is mainly for ios devices\r\n\t\t\t\tanimated : true\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\tdetailView.open();\r\n\t\t}\r\n\t};\r\n\r\n\tfunction handleSwitchButtonChanges(event) {\r\n\t\tif (event.value) {\r\n\t\t\t/**\r\n\t\t\t * i need to enable push notification\r\n\t\t\t */\r\n\t\t\tretrieveDeviceToken(function(err) {\r\n\t\t\t\tif (!err) {\r\n\t\t\t\t\tsubscribeToChannel();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\t/**\r\n\t\t\t * i need to disable push notification\r\n\t\t\t */\r\n\t\t\tretrieveDeviceToken(function(err) {\r\n\t\t\t\tif (!err) {\r\n\t\t\t\t\tunsubscribeToChannel();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tfunction createSwitchButton(text) {\r\n\t\tswitchButton.value = false;\r\n\t\tswitchButton.itemId = 'swicthButton';\r\n\t\tswitchButton.right = '6dp';\r\n\r\n\t\tvar firstBoot = Ti.App.Properties.getBool(firstBootKey, true);\r\n\t\tif (firstBoot) {\r\n\t\t\tswitchButton.value = true;\r\n\t\t\tretrieveDeviceToken(function(err) {\r\n\t\t\t\tif (!err) {\r\n\t\t\t\t\tsubscribeToChannel();\r\n\t\t\t\t\tTi.App.Properties.setBool(firstBootKey, false);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tswitchButton.value = false;\r\n\t\t\t\t\tTi.App.Properties.setBool(firstBootKey, true);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t} else {\r\n\t\t\tvar pnIsEnabled = Ti.App.Properties.getBool(pnEnabledKey, false);\r\n\t\t\tvar tokenIsAvailable = Ti.App.Properties.getString(pnEnabledKey, '');\r\n\t\t\tif (tokenIsAvailable && pnIsEnabled) {\r\n\t\t\t\tswitchButton.value = true;\r\n\t\t\t} else {\r\n\t\t\t\tswitchButton.value = false;\r\n\t\t\t}\r\n\t\t}\r\n\t\tswitchButton.addEventListener('change', handleSwitchButtonChanges);\r\n\r\n\t\tif (osname === 'android') {\r\n\t\t\tswitchButton.style = Titanium.UI.Android.SWITCH_STYLE_CHECKBOX;\r\n\t\t}\r\n\t\tvar row = Ti.UI.createTableViewRow({\r\n\t\t\titemId : text,\r\n\t\t\theight : '40dp',\r\n\t\t\twidth : Ti.UI.FILL,\r\n\t\t\tclassName : 'leftDrawer'\r\n\t\t});\r\n\r\n\t\tvar label = Ti.UI.createLabel({\r\n\t\t\ttext : L(text),\r\n\t\t\tcolor : 'black',\r\n\t\t\tfont : {\r\n\t\t\t\tfontSize : '14dp',\r\n\t\t\t\tfontWeight : 'bold'\r\n\t\t\t},\r\n\t\t\titemId : text\r\n\t\t});\r\n\t\tlabel.left = (osname === 'iphone') ? '15dp' : '3dp';\r\n\r\n\t\trow.add(label);\r\n\t\trow.add(switchButton);\r\n\r\n\t\treturn row;\r\n\t};\r\n\r\n\t/**\r\n\t * will create a view to apply it as header view to the table\r\n\t */\r\n\tvar tableViewSectionHeaderView = Ti.UI.createView({\r\n\t\tbackgroundColor : 'black',\r\n\t\theight : '20dp'\r\n\t});\r\n\tvar dateHeaderView = Ti.UI.createLabel({\r\n\t\tcolor : 'white',\r\n\t\tfont : {\r\n\t\t\tfontSize : '13dp'\r\n\t\t},\r\n\t\tleft : '10dp',\r\n\t\ttext : L('settings_title')\r\n\t});\r\n\ttableViewSectionHeaderView.add(dateHeaderView);\r\n\tvar settingsSection = Ti.UI.createTableViewSection({\r\n\t\theaderView : tableViewSectionHeaderView\r\n\t});\r\n\r\n\tsettingsSection.add(createSwitchButton('push_notifications'));\r\n\r\n\tvar table = Ti.UI.createTableView({\r\n\t\tdata : [settingsSection],\r\n\t\tbackgroundGradient : {\r\n\t\t\ttype : 'linear',\r\n\t\t\tstartPoint : {\r\n\t\t\t\tx : '0%',\r\n\t\t\t\ty : '50%'\r\n\t\t\t},\r\n\t\t\tendPoint : {\r\n\t\t\t\tx : '100%',\r\n\t\t\t\ty : '50%'\r\n\t\t\t},\r\n\t\t\tcolors : [{\r\n\t\t\t\tcolor : '#e2dddb',\r\n\t\t\t\toffset : 0.0\r\n\t\t\t}, {\r\n\t\t\t\tcolor : '#ebe6e5',\r\n\t\t\t\toffset : 0.25\r\n\t\t\t}, {\r\n\t\t\t\tcolor : '#e2dddb',\r\n\t\t\t\toffset : 1.0\r\n\t\t\t}],\r\n\t\t}\r\n\t});\r\n\r\n\treturn table;\r\n};\r\n\r\nmodule.exports = TableMenu;\r\n\r\n{code}", "updateAuthor": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "created": "2014-10-16T07:51:53.000+0000", "updated": "2014-10-16T07:51:53.000+0000" }, { "id": "328303", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Also would you please give me your app key for this problem, I can check the push notification status from our back end. \r\nFor security season, you can sent the app key to my email directly. \r\nsliang@appcelerator.com", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2014-10-16T08:02:52.000+0000", "updated": "2014-10-16T08:02:52.000+0000" }, { "id": "328304", "author": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "body": "sent", "updateAuthor": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "created": "2014-10-16T08:05:22.000+0000", "updated": "2014-10-16T08:05:22.000+0000" }, { "id": "328312", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Hi,\r\n\r\nTried your code in my environment, can't reproduce your problem.\r\nSo here is the suggest may help:\r\n1. Try to sent a short payload notification from web console.\r\n2. Try this simple code in your device, make sure it is not device problem.\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : '#ccc',\r\n\ttitle : '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.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\ttitle : 'Register For Push Notification',\r\n\tcolor : '#000',\r\n\theight : 60,\r\n\twidth : 200,\r\n\ttop : 100,\r\n});\r\n \r\nwin.add(submit);\r\n \r\nsubmit.addEventListener('click', function(e) {\r\n\tloginDefault();\r\n});\r\n \r\n \r\nCloudPush.retrieveDeviceToken({\r\n\tsuccess : deviceTokenSuccess,\r\n\terror : deviceTokenError\r\n});\r\n \r\n// Save the device token for subsequent API calls\r\nfunction deviceTokenSuccess(e) {\r\n\tdeviceToken = e.deviceToken;\r\n}\r\n \r\nfunction deviceTokenError(e) {\r\n\talert('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\talert(\"Notification received: \" + evt.payload);\r\n});\r\n \r\nfunction loginDefault(e) {\r\n\t// At first you need to create an user from the application dashboard\r\n\t// Then login that email and password\r\n\tCloud.Users.login({\r\n\t\tlogin : 'Email',\r\n\t\tpassword : 'pass'\r\n\t}, function(e) {\r\n\t\tif (e.success) {\r\n\t\t\talert(\"login success\");\r\n\t\t\tdefaultSubscribe();\r\n\t\t} else {\r\n\t\t\talert('Error: ' + ((e.error && e.message) || JSON.stringify(e)));\r\n\t\t}\r\n\t});\r\n}\r\n \r\nfunction defaultSubscribe() {\r\n\tCloud.PushNotifications.subscribe({\r\n\t\tchannel : 'alert',\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\talert('Subscribed for Push Notification!');\r\n\t\t} else {\r\n\t\t\talert('Error:' + ((e.error && e.message) || JSON.stringify(e)));\r\n\t\t}\r\n\t});\r\n}\r\n \r\nwin.open();\r\n{code}\r\n3.Before run and test your app, clean your project first.\r\n4.Would you please tell me which type of device did you use for the test.\r\nI noticed there are 3 android devices subscribed in Channel \"aztag_news\", did all of them have same problem? \r\n\r\nHope this will help.\r\n\r\nRegard,\r\nShuo", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2014-10-16T09:38:59.000+0000", "updated": "2014-10-16T09:38:59.000+0000" }, { "id": "328314", "author": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "body": "Hey,\r\n\r\nwhen i faced this problem i was sending really short messages like \"test\" or \"test push notification\".\r\nI am testing on a nexus 4 device.\r\nOne thing i also am facing is that the notification never arrive if the app is not running and when i re open the application it displays a black screen and eventually force closes\r\n\r\nI also noticed the following in the console\r\n{code}\r\n[ERROR] : GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.\r\n{code}", "updateAuthor": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "created": "2014-10-16T10:51:34.000+0000", "updated": "2014-10-16T10:52:57.000+0000" }, { "id": "328315", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Please try to create new project with my test code, see if it works well in your environment. \r\n\r\nThe [ERROR] : GooglePlayServicesUtil: will not bother the push notification we used as long as you can get device token and subscribe channel. ", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2014-10-16T11:24:36.000+0000", "updated": "2014-10-16T11:24:36.000+0000" }, { "id": "329714", "author": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "body": "is there any problems with the push notification service, yesterday i tried it and i received the push notifications while today i am not receiving anything", "updateAuthor": { "name": "fouadkada", "key": "fouadkada", "displayName": "Fouad Kada", "active": true, "timeZone": "Asia/Beirut" }, "created": "2014-10-28T08:22:16.000+0000", "updated": "2014-10-28T08:22:16.000+0000" }, { "id": "361399", "author": { "name": "morahman", "key": "morahman", "displayName": "Motiur Rahman", "active": true, "timeZone": "Asia/Dhaka" }, "body": "Hello,\r\n\r\nNow push notification works as expected and get in due time if the network connection is available. Also application does not crash.\r\n\r\n*Result:* Issue is not reproducible with latest SDK.\r\n\r\n*Steps to Test:*\r\n1. Paste your code in app.js file.\r\n2. Add cloud and cloudpush module from tiapp.xml file.\r\n3. Set your API key and project ID to your dashboard project.\r\n4. Run this code with the testing environment.\r\n5. Subscribe and then send push from the dashboard.\r\n\r\n*Testing Environment:*\r\nCommand-Line Interface, version 4.1.2,\r\nTi SDK: 4.1.0.GA,\r\nAndroid Version: 4.2.2, 4.4.2, 5.1.0,\r\nti.cloudpush Version: 3.3.8,\r\nti.cloud Version: 3.2.9,\r\nStudio Version: 4.1.1\r\n\r\n*Test Code*\r\n{code:title=app.js}\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\r\n// Process incoming push notifications\r\nCloudPush.addEventListener('callback', function(evt) {\r\n\talert(\"Notification received: \" + evt.payload);\r\n});\r\n\r\nCloudPush.addEventListener('trayClickLaunchedApp', function(evt) {\r\n\talert(\"trayClickLaunchedApp\");\r\n});\r\n\r\nCloudPush.addEventListener('trayClickFocusedApp', function(evt) {\r\n\talert(\"trayClickFocusedApp\");\r\n});\r\n\r\n// Save the device token for subsequent API calls\r\nfunction deviceTokenSuccess(e) {\r\n\tdeviceToken = e.deviceToken;\r\n}\r\n\r\nfunction deviceTokenError(e) {\r\n\talert('Failed to register for push notifications! ' + e.error);\r\n}\r\n\r\nvar Cloud = require(\"ti.cloud\");\r\n\r\nfunction subscribeToChannel() {\r\n\t// Subscribes the device to the 'news_alerts' channel\r\n\t// Specify the push type as either 'android' for Android or 'ios' for iOS\r\n\tCloud.PushNotifications.subscribeToken({\r\n\t\tdevice_token : deviceToken,\r\n\t\tchannel : 'news_alerts',\r\n\t\ttype : Ti.Platform.name == 'android' ? 'android' : 'ios'\r\n\t}, function(e) {\r\n\t\tif (e.success) {\r\n\t\t\talert('Subscribed');\r\n\t\t} else {\r\n\t\t\talert('Error:\\n' + ((e.error && e.message) || JSON.stringify(e)));\r\n\t\t}\r\n\t});\r\n}\r\n\r\nvar win = Ti.UI.createWindow({\r\n\tbackgroundColor : \"#fff\"\r\n});\r\n\r\n// Create a Button.\r\nvar Subscribe = Ti.UI.createButton({\r\n\ttitle : 'Subscribe',\r\n\theight : Ti.UI.SIZE,\r\n\twidth : Ti.UI.SIZE,\r\n\ttop : 20,\r\n\r\n});\r\n\r\n// Listen for click events.\r\nSubscribe.addEventListener('click', function() {\r\n\tsubscribeToChannel();\r\n});\r\n\r\n// Add to the parent view.\r\nwin.add(Subscribe);\r\n\r\nwin.open();\r\n\r\n\r\n{code}\r\n\r\nThanks", "updateAuthor": { "name": "shossain", "key": "shossain", "displayName": "Shak Hossain", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2015-08-27T09:28:51.000+0000", "updated": "2015-08-28T03:21:09.000+0000" } ], "maxResults": 13, "total": 13, "startAt": 0 } } }