READ THIS FIRST

Update: 3-4-2016: If you're finding this blog and looking for information related to Azure Mobile Services, I'd strongly recommend checking out Azure Mobile Apps. Azure Mobile Apps is a new version (consider it a v2) of Azure's mobile backend support. All of the same features of Azure Mobile Services are there, with a lot of other very cool features to go along. You can read more about Azure Mobile Apps, and how to transition from Azure Mobile Services, here.

About a month and a half ago, we released Windows Azure Mobile Services to the world.  Today I’m happy to announce the initial release of our iOS SDK for Windows Azure Mobile Services.  This is not an officially “done” SDK but is still actively in development.  In addition to the iOS SDK supporting the majority of the features the Win8 SDK does, some new features made it in this release as well.  In this article, I’ll walk you through a high level overview of the features of the iOS SDK as well as some of the new things that have come out.  I’ll be posting deeper dives for relevant topics in the coming days.

Windows Azure accounts

In order to play around with Mobile Services and the iOS SDK, you’ll need a Windows Azure account.  You can sign up for a free account here.  When you sign up you’ll get a 3 month trial of some of the other features of Windows Azure, however, Mobile Services is a separate feature which is currently free during the preview period.

The SDK

You have a couple of different options for getting the iOS SDK.  Just like the Windows 8 managed client SDK, the iOS SDK has been open sourced to GitHub.  This means that not only do you have access to the source code, but you can fork it and contribute to it by making pull requests.  Additionally, now when you go to the quickstart page after creating a new mobile service, you’ll have links to download the iOS SDK in addition to a Xcode starter project that already has the SDK connected:

iOS options in Mobile Services Quickstart

Data storage

In the iOS SDK, you get the same data storage access as you do in the Win8 SDKs.  Under the covers, the SDK works by sending JSON over the wire to Mobile Services’ REST API.  If you’re using the SDK though, you don’t need to worry about that.  If you pull down the pre-created quick start project from the Windows Azure portal, you’ll have a service class that wraps the functionality for accessing data storage.  This class is instantiated with a table name.  With that done you can add and update items by passing a NSDictionary which contains each item in the table to the service class.  Deleting items is done by sending a NSDictionary over that just contains the item id.  Lastly, there are filtering methods which make use of the NSPredicate class to facilitate querying your table.

Authentication

When the Win8 SDK was launched, the only form of authentication that was supported were Windows Live accounts.  With the release of the iOS SDK, we’re also supporting Facebook, Twitter, and Google authentication.  In order to “turn these on” you need to go to the Windows Azure portal and enter the Identity settings for whichever app you want to authenticate to.  Prior to doing any of these, you’ll need to sign up at the correct site by creating a new application.  You can find links to where you sign up for these here:

Once you’ve set the identity settings in your app, you can then authenticate using methods in the MSClient class in the SDK.  You can read more about setting up and authenticating from an iOS app here.

Push Notifications

For this drop of the iOS SDK, push notifications aren’t supported.  These are coming and will be here before you know it.  Once they are, I’ll be announcing it.

Service Scripts

As with any other app you connect to Mobile Services, you get the same powerful service scripting triggers that are fired on any CRUD interaction with your data tables.  There is quite a lot you can do in these scripts (join to other tables, perform HTTP requests to other services, and more).  As of today, service scripts have access to the Azure SDK which means they can access blob storage, table storage, and more.  Also, the ability to send emails through SendGrid and SMS text messages through Twilio are now supported as well.

Conclusion

If you’re doing iOS development, you have to take a look at Windows Azure Mobile Services.  You can get your backend up and running in seconds and get some very powerful capabilities.  Mobile Services will help allow you to focus on creating the best mobile app you can, without worrying too much about how you’ll handle data storage or authentication.  Plus, we’ll be adding more features to Mobile Services very frequently in the future.  Stay tuned for info on all of these features and more.


Chris Risner


6 Comments

Chris

I feel your pain Colin. It's coming through. For now, You can get by using the REST API. I'm hoping to show a few more Android specific scenarios to help bridge the gap until a SDK is released.

Dave Westwood

Hi Chris, I'm trying to modify the Quickstart tutorial to support iOS 6 ACAccounts. How does loginWithProvider withToken work? You mentioned it in the episode 92 video, but I can't get it to work with a facebook oauth code. There's no description of what the dictionary "token" should contain. I have an ios 6 facebook account credential: self.facebookAccount.credential.oauthToken where faceAccount is an ACAccount. I know the oauth token is good - it works with the fb graph api. But how do I pass that to azure? I tried the following, but I don't think it tries to make an actual connection - the completion handler is never called.

NSDictionary *token = [NSDictionary dictionaryWithObjectsAndKeys:
self.facebookAccount.credential.oauthToken, @"access_token",nil];
[self.todoService.client loginWithProvider:@"facebook" withToken:token
completion:^(MSUser *user, NSError *error)
{
if (error)
{
NSLog(@"Authentication Error: %@", error);
}
else
{
// No error, so load the data
NSLog(@"no error");
[self.todoService refreshDataOnSuccess:^{
[self.tableView reloadData];
}];
}
}];
thanks!

Dave Westwood

Problem solved: the problem was I was calling this inside an SLRequest response. I needed to wrap it in dispatch_async( dispatch_get_main_queue(), ^{...}); Then it works great.

Leave a Comment