One of the most amazing feature on Microsoft Azure are the mobile Services, a set of tools that allows the developer to integrate cloud based features in their apps with extremely low efforts.
Azure Mobile Services are available trough an SDK for all the most modern mobile platforms (but we can also use REST APIs) and offer these services:
- Data Storage
- Push Notification
If we are developing our apps with Xamarin.Android or Xamarin.iOs then we can easily use them by following the instructions on the Azure Portal and there is practically no difference from how we would use them in Windows Phone or Windows 8.
AZURE MOBILE SERVICES & XAMARIN.FORMS
What is nice and strangely undocumented is that we can easily use the data and authentication features directly from our shared code:
- Install the AzureMobileServices Nuget in the Portable Class Library (if you’re using it) AND in all the platform specific projects
- In the iOS project, in the AppDelegate.cs add
- [Optional] If you want to use the Authentication features you need to add AMSLoginForms Nuget created by me, it’s a simple interface that let’s you use the method LoginAsync from the shared code.
- All done! Now you can access all the methods and use the Azure Mobile Services! 😀
AMSLoginForms is necessary because since we’re in a PCL we cant create the web browser needed to perform the OAuth 2.0 Authentication. If you at the code you will see that all it does is simply call the the appropriate method depending on the platform
If you need, here you can find a simple example app that writes the current time in a data table if you’re a logged in user.
To make it work remember to change the Mobile Service Key and Url in the App.cs file!