You can have your iOS applications such as those running on iPhone integrated with ACS. The Microsoft Developer and Platform Evangelism (DPE) team has released Windows Azure Toolkit for iOS, which allows the iOS application developers to easily integrate their applications with ACS and access Windows Azure Storage Services from native iOS applications.
You can download the iOS toolkit from https://github.com/WindowsAzure-Toolkits/wa-toolkit-ios.
To create an ACS-integrated iOS application, perform the following steps:
uri:wattoolkitiosdemo
and for the token format use SWT instead of SAML 2.0. .a
file (for the simulator) and the header files and add them to your project. You may create a new group (called lib) to store them in it. libwatoolkitios.a
file has been automatically added as a reference. Click on the + button to add a new library, and select the libxml2.dylib
library from the drop-down list. Click on the Add button to add a reference to this library for your project. #import
statement at the top of the class:#import "WACloudAccessControlClient.h"
didFinishLaunchingWithOptions
and after the [self.window makeKeyAndVisible]
line, enter the following code snippet:NSLog(@"Access Control Client Initialize"); WACloudAccessControlClient *acsClient = [WACloudAccessControlClient accessControlClientForNamespace: @"YOUR ACS NAMESPACE HERE" realm:@"YOUR REALM HERE"]; [acsClient showInViewController:self.viewController allowsClose:NO withCompletionHandler:^(BOOL authenticated) { if (!authenticated) { NSLog(@"Authentication Failed"); } else { NSLog(@"Creating the authentication token..."); WACloudAccessToken *acsToken = [WACloudAccessControlClient sharedToken]; /* Consume Token */ } }];
Replace the namespace and realm in the first line with the service namespace and the realm for your own service, as created in the first step.
As you can see from the preceding code snippet, the code creates a new instance of the access control client, requests that the client shows itself in the current view controller, and then extracts a token.
You've successfully integrated your iOS application with ACS.
The workings of this recipe are straightforward and similar to what you have seen before. The application running in the phone connects to ACS and pulls the list of the identity providers configured under your ACS namespace and as the user signs in to one of those providers, the identity provider token received is passed to ACS to retrieve the ACS token. The ACS token then can be used to perform various tasks such as calling the services in cloud as you have seen earlier in this chapter.