iOS apps
Live Connect provides an API for the iOS operating system for Apple devices. The iOS API enables your iPad, iPhone, and iPod touch apps running on iOS 4.3 or higher to work with info in Outlook.com, Microsoft OneDrive, and other services that are compatible with Live Connect. Although you can still write code to call the Live Connect Representational State Transfer (REST) API directly, the iOS API now makes your coding tasks easier.
Before you can start calling the Live Connect APIs, you need a client ID. For instructions, see Configuring your app.
Prerequisites
The Live Connect iOS API requires Xcode 4.1 or later. Xcode 4.1 runs on Mac OS X Snow Leopard (version 10.6) and OS X Lion (version 10.7), while Xcode 4.2 runs only on OS X Lion (version 10.7).
Referencing the iOS API with Objective-C
Before you can reference the Live Connect iOS API in an Xcode project, you must download the Live software development kit (SDK) for iOS. Here's how.
To download the Live SDK for iOS
-
Go to the website location where the Live SDK for iOS is stored and download the SDK for iOS.
Note If you download the Live SDK for iOS as a zip file, you must extract the contents of the zip file before you follow the steps in the next section.
You can now reference the iOS API.
To reference the iOS API
You can reference the iOS API in two ways. We recommend that you reference the iOS API framework. However, you can reference the iOS API source code directly if you need to modify it or want to see how it works.
To reference the iOS API framework
- Open your iOS project in Xcode, if you haven't already done so.
- In the Project Navigator, click your project.
- In the project editor, in the Targets area, click your project.
- Click Build Phases.
- Expand Link Binary With Libraries, and then click Add items (+).
- Click Add Other.
- Go to and select the LiveSDK.framework folder within the downloaded Live SDK for iOS, and then click Open.
- In the Project Navigator, drag the LiveSDK.framework node and drop it into Build Phases tab's Copy Bundle Resources table in the project editor.
- For each code file from which you want to reference the iOS API framework, add this import statement:
#import "LiveSDK/LiveConnectClient.h".
To reference the iOS API source code directly
- Open your iOS project in Xcode, if you haven't already done so.
- Click File > Add Files to "Your Project Name".
- Go to and select the Library folder within the downloaded Live SDK for iOS, and then click Add.
- For each code file from which you want to reference the API source code, add this import statement:
#import "LiveConnectClient.h".
- Follow the steps listed earlier in this section.
- On the Xcode menu, click Xcode > Preferences and select the Continue building after errors check box.
- On the Xcode menu, click Edit > Refactor > Convert to Objective-C ARC.
- Follow the on-screen directions.
Code sample
To get you started, here's the basic code that shows how to reference the iOS APIs, invite a user to sign in, and get the signed-in user's permission to get his or her basic profile info.
ViewController.h
#import <UIKit/UIKit.h> #import "LiveSDK/LiveConnectClient.h" @interface ViewController : UIViewController<LiveAuthDelegate, LiveOperationDelegate, LiveDownloadOperationDelegate, LiveUploadOperationDelegate> @property (strong, nonatomic) LiveConnectClient *liveClient; @property (strong, nonatomic) IBOutlet UILabel *infoLabel; @end
ViewController.m (where APP_CLIENT_ID is your app's client ID)
#import "ViewController.h"
@implementation ViewController
@synthesize liveClient;
@synthesize infoLabel;
NSString* APP_CLIENT_ID=@"000000004406774C";
- (void)viewDidLoad
{
[super viewDidLoad];
self.liveClient = [[LiveConnectClient alloc] initWithClientId:APP_CLIENT_ID
delegate:self
userState:@"initialize"];
}
- (void)authCompleted:(LiveConnectSessionStatus) status
session:(LiveConnectSession *) session
userState:(id) userState
{
if ([userState isEqual:@"initialize"])
{
[self.infoLabel setText:@"Initialized."];
[self.liveClient login:self
scopes:[NSArray arrayWithObjects:@"wl.signin", nil]
delegate:self
userState:@"signin"];
}
if ([userState isEqual:@"signin"])
{
if (session != nil)
{
[self.infoLabel setText:@"Signed in."];
}
}
}
- (void)authFailed:(NSError *) error
userState:(id)userState
{
[self.infoLabel setText:[NSString stringWithFormat:@"Error: %@", [error localizedDescription]]];
}
@end
Configuring your app to participate in the Microsoft OneDrive app experience
There is a Microsoft OneDrive app that users can install on an iPhone or iPad device. They can then use this app to upload files to, or view files from, their OneDrive storage location. You can configure your app to participate in the file uploading and viewing experiences in the Microsoft OneDrive app. This can save you coding time and make for a better user experience.
In one scenario, a user can upload a file from your app to his or her OneDrive storage location by using the Microsoft OneDrive app. You don't have to write code in your app to upload the file directly; you can let the Microsoft OneDrive app upload the file instead. Here's how it works. When the user is viewing a file (like a document or a photo) within your app, you can let the user open the file in the Microsoft OneDrive app. Your app can use the UIDocumentInteractionController class to pass the file to the Microsoft OneDrive app, in which the user can then choose where to upload the file. After the Microsoft OneDrive app opens the file, the user taps the Upload command, taps the folder in his or her OneDrive location to upload the file to, and then the Microsoft OneDrive app uploads the file to that folder.
In another scenario, a user can use the Microsoft OneDrive app to view a file from his or her OneDrive storage location in your app. This enables a seamless user experience for viewing files, especially for custom file types that aren't associated with apps that might already be installed on the user's device. Here's how it works. In the Microsoft OneDrive app, the user taps the file to open it from his or her OneDrive location, and then taps the Open in Another App command that's displayed. The Microsoft OneDrive app then displays a list of apps that the user can choose from to view the file. If your app is registered to work with that file's type, your app appears in the list. When the user taps your app in the list, your app then displays that file.
For details about how your apps can participate in these experiences, see About Document Interaction in the iOS Developer Library documentation.
Next steps
From here, we suggest that you continue your learning with the info in Core concepts, Identity API, Outlook.com API, and OneDrive API.