{"action":"created","issue":{"url":"https://api.github.com/repos/phonegap-build/PushPlugin/issues/313","labels_url":"https://api.github.com/repos/phonegap-build/PushPlugin/issues/313/labels{/name}","comments_url":"https://api.github.com/repos/phonegap-build/PushPlugin/issues/313/comments","events_url":"https://api.github.com/repos/phonegap-build/PushPlugin/issues/313/events","html_url":"https://github.com/phonegap-build/PushPlugin/issues/313","id":42928298,"number":313,"title":"PushPlugin onNotificationGCM does not fire","user":{"login":"ibkhalid","id":6694637,"avatar_url":"https://avatars.githubusercontent.com/u/6694637?v=3","gravatar_id":"","url":"https://api.github.com/users/ibkhalid","html_url":"https://github.com/ibkhalid","followers_url":"https://api.github.com/users/ibkhalid/followers","following_url":"https://api.github.com/users/ibkhalid/following{/other_user}","gists_url":"https://api.github.com/users/ibkhalid/gists{/gist_id}","starred_url":"https://api.github.com/users/ibkhalid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ibkhalid/subscriptions","organizations_url":"https://api.github.com/users/ibkhalid/orgs","repos_url":"https://api.github.com/users/ibkhalid/repos","events_url":"https://api.github.com/users/ibkhalid/events{/privacy}","received_events_url":"https://api.github.com/users/ibkhalid/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2014-09-16T20:19:45Z","updated_at":"2016-01-29T15:21:33Z","closed_at":null,"body":"I have done extensive research - but not able to resolve. \r\n\r\nI am using the Phonegap build service:\r\n- Works fine for IoS \r\n- On Android devices onNotificationGCM never get fired\r\n- I have confirmed and reconfirmed the application-id \r\n- Would greatly appreciate any help with debugging / resolving the issue.\r\n- my code below:\r\n\r\nfunction onDeviceReady(){\r\n\tSetupPush();\r\n}\r\n\r\nfunction SetupPush(){\r\n\tvar pushNotification;\r\n\tpushNotification = window.plugins.pushNotification;\r\n\twindow.localStorage.setItem(\"Platform\", device.platform);\r\n\t\r\n\tif ( device.platform == 'android' || device.platform == 'Android' )\t{\r\n\t    alert(\"before sending push\");\r\n\t\tpushNotification.register(\r\n\t\t\tsuccessHandler,\r\n\t\t\terrorHandler, {\r\n\t\t\t\t\"senderID\":'xyzabc',\r\n\t\t\t\t\"ecb\":\"onNotificationGCM\"\r\n\t\t\t});\t\r\n\t} else {\r\n\t\tpushNotification.register(\r\n\t\t\ttokenHandler,\r\n\t\t\terrorHandler, {\r\n\t\t\t\t\"badge\":\"true\",\r\n\t\t\t\t\"sound\":\"true\",\r\n\t\t\t\t\"alert\":\"true\",\r\n\t\t\t\t\"ecb\":\"onNotificationAPN\"\r\n\t\t\t});\r\n\t};\r\n}\r\n\r\nfunction successHandler (result) {\r\n   alert('result = ' + result);\r\n}\t\t\r\n\r\nfunction errorHandler (error) {\r\n //   alert('error = ' + error);\r\n}\r\n\r\nfunction tokenHandler (result) {\r\n\twindow.localStorage.setItem(\"Token\", result);\t\r\n}\r\n\r\nfunction onNotificationAPN (event) {\r\n\talert(event.action);\r\n    if ( event.alert ) {\r\n        navigator.notification.alert(event.alert);\r\n    }\r\n\r\n    if ( event.sound ) {\r\n        var snd = new Media(event.sound);\r\n        snd.play();\r\n    }\r\n\r\n    if ( event.badge ) {\r\n        pushNotification.setApplicationIconBadgeNumber(successHandler, errorHandler, event.badge);\r\n    }\r\n}\r\n\r\n\r\nonNotificationGCM=function(e) {\r\n    alert(\"i am here\");\r\n    $(\"#app-status-ul\").append('<li>EVENT -> RECEIVED:' + e.event + '</li>');\r\n\talert(e.event);\r\n\talert(e.regid);\r\n    switch( e.event ) {\r\n    case 'registered':\r\n        if ( e.regid.length > 0 ) {\r\n\t\t\twindow.localStorage.setItem(\"Token\", e.regid);\r\n\t\t\talert(\"setup local storage\")\r\n\t\t\tvar detailurl = 'http://alerttown.com/server/create_device.php?userphone=' + window.localStorage.getItem(\"LocalProfilePhone\") + \r\n\t\t\t\t\t\t\t\t'&platform=' + window.localStorage.getItem(\"Platform\") +\r\n\t\t\t\t\t\t\t\t'&token=' + window.localStorage.getItem(\"Token\") ;  \t\t\t\t\t\r\n\t\t\t$.ajax({url: detailurl,\tdataType: 'jsonp', async: true,\tsuccess: function(json){}, complete: function(json){}});\t\t\r\n\t\t}\r\n    break;\r\n\r\n    case 'message':\r\n        // if this flag is set, this notification happened while we were in the foreground.\r\n        // you might want to play a sound to get the user's attention, throw up a dialog, etc.\r\n        if ( e.foreground )\r\n        {\r\n            $(\"#app-status-ul\").append('<li>--INLINE NOTIFICATION--' + '</li>');\r\n\r\n            // if the notification contains a soundname, play it.\r\n            var my_media = new Media(\"/android_asset/www/\"+e.soundname);\r\n            my_media.play();\r\n        }\r\n        else\r\n        {  // otherwise we were launched because the user touched a notification in the notification tray.\r\n            if ( e.coldstart )\r\n            {\r\n                $(\"#app-status-ul\").append('<li>--COLDSTART NOTIFICATION--' + '</li>');\r\n            }\r\n            else\r\n            {\r\n                $(\"#app-status-ul\").append('<li>--BACKGROUND NOTIFICATION--' + '</li>');\r\n            }\r\n        }\r\n\r\n        $(\"#app-status-ul\").append('<li>MESSAGE -> MSG: ' + e.payload.message + '</li>');\r\n        $(\"#app-status-ul\").append('<li>MESSAGE -> MSGCNT: ' + e.payload.msgcnt + '</li>');\r\n    break;\r\n\r\n    case 'error':\r\n        $(\"#app-status-ul\").append('<li>ERROR -> MSG:' + e.msg + '</li>');\r\n    break;\r\n\r\n    default:\r\n        $(\"#app-status-ul\").append('<li>EVENT -> Unknown, an event was received and we do not know what it is</li>');\r\n    break;\r\n  }\r\n}\r\n"},"comment":{"url":"https://api.github.com/repos/phonegap-build/PushPlugin/issues/comments/176807117","html_url":"https://github.com/phonegap-build/PushPlugin/issues/313#issuecomment-176807117","issue_url":"https://api.github.com/repos/phonegap-build/PushPlugin/issues/313","id":176807117,"user":{"login":"MingyuJeon","id":15281293,"avatar_url":"https://avatars.githubusercontent.com/u/15281293?v=3","gravatar_id":"","url":"https://api.github.com/users/MingyuJeon","html_url":"https://github.com/MingyuJeon","followers_url":"https://api.github.com/users/MingyuJeon/followers","following_url":"https://api.github.com/users/MingyuJeon/following{/other_user}","gists_url":"https://api.github.com/users/MingyuJeon/gists{/gist_id}","starred_url":"https://api.github.com/users/MingyuJeon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MingyuJeon/subscriptions","organizations_url":"https://api.github.com/users/MingyuJeon/orgs","repos_url":"https://api.github.com/users/MingyuJeon/repos","events_url":"https://api.github.com/users/MingyuJeon/events{/privacy}","received_events_url":"https://api.github.com/users/MingyuJeon/received_events","type":"User","site_admin":false},"created_at":"2016-01-29T15:21:33Z","updated_at":"2016-01-29T15:21:33Z","body":"Thanks @arnelceledonio\r\nBecause of you I fixed my code!"}}