I’ve successfully created providers that can talk to Azure App Service. However, I am struggling with a working approach to create a working provider that can be used across my application. The underlying Mobile Apps JS SDK has an object named WindowsAzure.MobileServicesClient. It’s important to create this object once in your application versus every time you make an API call as it keeps track of the user’s authentication. Therefore, Provider1 and Provider2 have to both use the same object.
For example, I create some provider called AzureService and my other providers import this. I register the providers in my App.Module.ts file so that they can be accessed anywhere. However, when I do that and I later go to use the WindowsAzure object, it is not defined. This is not the typical WindowsAzure is not defined error because I didn’t declare it in the module. It’s actually failing because the provider is running before platform.ready() fires. That has to occur otherwise, you’ll get errors like these.
So here is the part where I am not sure how to proceed. How do I use my provider across the pages in my application but ensure that platform.ready() fires first? I’m sure if I had more experience with Angular 2 and Ionic 2, the answer might be obvious but I am confused on this one.