Ionic and Parse.com Javascript SDK failing to initialise

Hi all.

I am having some trouble integrating the Parse.com Javascript SDK into my project. I have looked all over for a solution but can’t find one.

I followed the instructions located in the following link: https://blog.nraboy.com/2015/04/use-parse-core-in-ionic-framework-mobile-apps/

As suggested I have included the latest parse.js file in my index.html, I have put the following code into app.js under the $ionicPlatform.ready() method (using my appID and JSID taken from Parse): Parse.initialize("APP_ID_HERE", "JAVASCRIPT_ID_HERE");

I am also using the Parse Angular Patch https://github.com/brandid/parse-angular-patch and have followed all instructions for this. i.e. including the patch.js file in index.html and adding the code to app.js like so: angular.module('myApp', ['ngAnimate', 'parse-angular'])

I have excluded the Parse Angular Patch also to make sure it is not this causing the issue, the issue remains in the absence of the patch.

In my controller I have the following code

var query = new Parse.Query("testUser");
    query.equalTo("facebookID", "10101185732529923");
    query.find()
    .then(function(result){
        console.log(result);
    });

Initially this worked and logged the data from Parse but then stopped. Every 10-20 attempts it seems to work once but otherwise gives the following error in the console:

You must specify your applicationId using Parse.initialize. <ion-nav-view name="tab-nudges" class="view-container tab-content" nav-view="active" nav-view-transition="ios"> ionic.bundle.js:20306

I don’t understand this as it is clearly specified in app.js and works sometimes. Any help would be very much appreciated.

Thanks

Ant

i know alot of people are recommending using the parse-angular-patch, but I have a simple straight forward implementation just using the REST APIs that might help you get started.

Hi,

I am getting same error sporadically while running my app on browser or iphone. I dont want to use any other api to fix it.

Did you get some better solution ?

Hey @antonfire,

I think I found the solution.

All you need to do is just move your code out from $ionicPlatform.ready.

Like:
angular.module().run(function($ionicPlatform) {
Parse.initialize(“APP_ID_HERE”, “JAVASCRIPT_ID_HERE”); // this is the new place
$ionicPlatform.ready(function() {});
}

Thanks @jainank that worked like a charm :smile: