Skip to content

Parse push notifications #3

Description

@mymanga

Following this guide to add Parse push notification along with phonegap push plugin;

https://stackoverflow.com/questions/36851056/parse-push-notifications-on-ionic-cordova-invalid-device-token/37233155

My code;

//Push
    var push = PushNotification.init({
      android: {
          senderID: "XXXXXXX"
      },
      ios: {
          alert: "true",
          badge: "true",
          sound: 'false'
      },
      windows: {}
    });

push.on('registration', function(data) {
      User.pushInstallation(platform, data.registrationId);
})
      //Push

      //Parse   
    Parse.initialize("XXXXXX", "XXXXX");
    Parse.serverURL = 'https://api.parse.com/1/'

    var parseInstallationId = Parse._getInstallationId().then(function(inId){

      var d = {
        "deviceType": platform,  
        "deviceToken": registrationId,
        "channels": ["installed"],
        "installationId":inId
      }
      var userId = Parse.User.current().id; 
      d['user'] = {
        "__type": "Pointer",
        "className": "_User",
        "objectId": userId
      }
      if(platform === 'android'){
        d.pushType = 'gcm';
      }

      $http({
        method: 'POST',
       url: 'https://api.parse.com/1/installations/',
        headers: {'X-Parse-Application-Id': 'myapp','X-Parse-Client-Key': 'mykey'},
        data: d
      }).then(function successCallback(response) {
          installationId = response;
        }, 
        function errorCallback(response) {
          console.log('pushInstallation error: ', response);
      });
    })
    //Parse

I get the following error on Android

8836-8904/com.example.test V/PushPlugin: execute: action=init
05-15 04:00:02.371 8836-9033/com.example.test V/PushPlugin: execute: data=[{"android":{"senderID":"XXXXXXX"},"ios":{"alert":"true","badge":"true","sound":"false"},"windows":{}}]
05-15 04:00:02.372 8836-9033/com.example.test V/PushPlugin: execute: jo={"senderID":"XXXXXXX"}
05-15 04:00:02.372 8836-9033/com.example.test V/PushPlugin: execute: senderID=XXXXXXX
05-15 04:00:02.403 8836-8836/com.example.test I/chromium: [INFO:CONSOLE(426)] "Uncaught ReferenceError: platform is not defined", source: file:///android_asset/www/app/app.js (426)
05-15 04:00:02.806 8836-9033/com.example.test W/InstanceID/Rpc: Found 10020
05-15 04:00:03.133 8836-9033/com.example.test W/InstanceID: token: fCqRvGfJZbs:APA91bGoZRoBc9vIN7wB_nx02vJhpzuBLlHqPAkXhXE_-7t0DioqnAJl6n_J8RrwHjpnu0CCA2KDmRKhjImY5P83Z4Y8dUEvbfzXCrvCSKSOpcV_MjCcqYqfA4LujQ87KpQHbqVP-kjh
05-15 04:00:03.140 8836-9033/com.example.test V/PushPlugin: onRegistered: {"registrationId":"fCqRvGfJZbs:APA91bGoZRoBc9vIN7wB_nx02vJhpzuBLlHqPAkXhXE_-7t0DioqnAJl6n_J8RrwHjpnu0CCA2KDmRKhjImY5P83Z4Y8dUEvbfzXCrvCSKSOpcV_MjCcqYqfA4LujQ87KpQHbqVP-kjh"}
05-15 04:00:03.140 8836-9033/com.example.test D/PushPlugin: no icon option
05-15 04:00:03.140 8836-9033/com.example.test D/PushPlugin: no iconColor option
05-15 04:00:03.150 8836-8836/com.example.test I/chromium: [INFO:CONSOLE(312)] "Error in Success callbackId: PushNotification749137166 : ReferenceError: User is not defined", source: file:///android_asset/www/cordova.js (312)
05-15 04:00:03.153 8836-8836/com.example.test I/chromium: [INFO:CONSOLE(314)] "Uncaught ReferenceError: User is not defined", source: file:///android_asset/www/cordova.js (314)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions