Parse Plugin issue

Hi All,
I’m trying to use this Parse Plugin in app.js but due to some issue the plugin is not working when i integrate it with my project. I followed the steps below

  1. Create Blank Ionic demo project.

  2. Run this command
    cordova plugin add https://github.com/benjie/phonegap-parse-plugin

  3. ionic platform add android

  4. App.js looks like this

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
    parsePlugin.initialize('XXX', 'XXX', function() {
        alert('success');
    }, function(e) {
        alert('error');
    });
})
})

This works fine and as expected, which means the plugin is installed properly and works fine.

Issue

But, then I replace my project’s www folder to the demo projects www and then do the same task. In this case I am getting alert parsePlugin undefined.

Main project App.js Looks like this

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}

/*Parse Notifications */

try{
parsePlugin.initialize(‘XXX’, ‘XXX’, function() {
alert(‘success’);
}, function(e) {
alert(‘error’);
});

}catch(err){
alert('Message from Parse '+err);

}
});
})

Any tips for debugging the issue?

Hi

Not sure why you need to use the ParsePlugin??

You can do Parse.com push without this plugin

Use parseInstallationId = Parse._getInstallationId();

This is undocumented function - I have been using it for a year now

Darren

Thanks for reply @darrenahunter
ok so you’re saying we don’t need the plugin at all?
In that case can we directly write
Parse.initialize("XXX","XXX") in app.js? please provide some link or code snippet.

yes you can
you just need the parse sdk loaded

I use

Parse.initialize(CommonService.parse_appkey, CommonService.parse_jskey );
CommonService.parseInstallationId = Parse._getInstallationId();

Here is what I am doing.

1.Downloaded parse.js
2. Included it in index.html
3. In app.js
Parse.initialize(appId, jsID);

There is no error, but I can’t see the installation in Parse dashboard.
Is there something I am missing?

Thanks

Parse.initialize(Xxx,xxx) doesn’t add your installation to the Parse database - it runs locally on the client and really just sets the appid and jsid for use in other parse calls. you need to call parse._getInstallationId and then run the rest api call to add the installation to the devices database

OK, so there are few problems in the above approach.

a. I am targeting android users so my call using REST API looks like this

data:{
“deviceType”: “android”,
“pushType”: “gcm”,
“deviceToken”: “0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef”,
}

Now the device gets registered to the Parse and I can also see it in dashboard.

But, now if I try to push notification using CURL of REST API it is not received in emulator. Parse says

If you upload Android installations with GCM credentials, then you must also set the GCM API Key associated with this GCM sender ID in your application’s push settings

So, I’ll require GCM Credentials, right?

b. Sending a REST API we’ll need to generate device Type unique for every device.

c. the Plugin that I mentioned in the question handles all this.

Can you please share your implementation.

Thanks

I am about to start integrating Android and was wondering if @jjpatel361 figured out how to send Push Notification to Android devices?
I was lucky enough to get iOS pushes work with Parse Plugin plugin.

Any help will be much appreciated.

Thanks

Hi @kikados
I am done with integrating the Parse Plugin with Android. I used this plugin https://github.com/avivais/phonegap-parse-plugin . It works fine, but the problem is the plugin is outdated (based on Parse 1.3 and latest version is 1.8 and has many methods of 1.3 as deprecated) and unfortunately the author has lost interest in updating the repo.

But, for the basics, the plugin gets our work done. Private Message me if you have any more issues or want some info.

Hi all !
For your info, plugin does not seem to be outdated anymore since it’s now using Parse 1.9.

1 Like

i have added parse plugin using the steps mentioned in the https://github.com/avivais/phonegap-parse-plugin
but still i get "parsePlugin is not defined"
on initializing in app.js like “parsePlugin.initialize(appId, clientKey, function()”

any ideas

Hi! I am getting the same error. Did you figure it out?

What is this jsID? The appId is that ID you get from Facebook Apps, but how about this other one?