Reputation: 121
On my Cordova mobile app I am an using cordova-plugin-ms-azure-mobile-apps Following Agular's methodologic, I am creating a factory that creates WindowsAzurethe client:
var client = new WindowsAzure.MobileServiceClient('https://XXX.azurewebsites.net');
When app start on a mobile device I am getting: "ReferenceError: WindowsAzure is not defined" .
On the Ripple its working ok (no error) And If I postpone the factory, and create the client only when it actually needed there is also no problem.
So do the factory run before the plugins are created? What is the best/recommended methodologic to use?
Upvotes: 1
Views: 620
Reputation: 8035
There are two ways of using the HTML/JS SDK - one is via the npmjs.org package (search for azure-mobile-apps-client) - this is best if you are using Browserify or Webpack to package your app. The other is the Apache Cordova Plugin that you referenced. Both have the same code - one registers a global, whereas the other is a UMD package that can be used with require.js or commonjs systems. The important distinction is that the plugin is not available until the deviceReady event has fired.
If a plugin is not available in the emulators but is available in Ripple, it's pretty much always because the plugin is being accessed prior to deviceReady. Ripple loads the plugins earlier than the emulators or real devices.
Upvotes: 1