1

I am using parse-phonegap-plugin-push to register cordova android app with google cloud messaging. But it did not return anything.

I ran the app in Android Device but still did not get anything and double checked my sender id also. I am using cordova in visual studio 2017.

Code:

 function onDeviceReady() {
    document.addEventListener( 'pause', onPause.bind( this ), false );
    document.addEventListener('resume', onResume.bind(this), false);

    var push = PushNotification.init({
        "android": { "senderID": "XXXXXXXXXX" },
        "ios": { "alert": "true", "badge": "true", "sound": "true" }, "windows": {}
    });

    push.on('registration', function (data) {
        console.log(data.registrationId);
        document.getElementById("gcm_id").innerHTML = data.registrationId;
        // data.registrationId 
    });

    push.on('notification', function (data) {
        // data.message, 
        // data.title, 
        // data.count, 
        // data.sound, 
        // data.image, 
        // data.additionalData 
    });

    push.on('error', function (e) {
        console.log(data.message);
        document.getElementById("gcm_id").innerHTML = data.message;
    });
};
ZF007
  • 3,708
  • 8
  • 29
  • 48
  • i am using cordova in visual studio 2017 –  Feb 19 '18 at 09:20
  • It should work. Did you include internet connection? Is there any log error? – proofzy Feb 19 '18 at 09:52
  • "include internet connection" mean having internet connection then yes, it did not throw any error –  Feb 19 '18 at 10:59
  • You may check the workaround given in this [thread: Using this Plugin with Parse.com results in not showing Push on Android](https://github.com/phonegap/phonegap-plugin-push/issues/147). It suggested to make the title and message keys configurable. You may also refer with this [link](https://github.com/phonegap/phonegap-plugin-push/issues/783). – abielita Feb 19 '18 at 15:49

0 Answers0