Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse push notifications #3

Open
mymanga opened this issue May 15, 2016 · 4 comments
Open

Parse push notifications #3

mymanga opened this issue May 15, 2016 · 4 comments

Comments

@mymanga
Copy link

mymanga commented May 15, 2016

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)

@triniwiz
Copy link
Member

I never used push notification but i'll see what i can do

@mymanga
Copy link
Author

mymanga commented May 15, 2016

Thanks

@mymanga
Copy link
Author

mymanga commented May 26, 2016

Any hope?

@triniwiz
Copy link
Member

Nothing yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants