Skip to content

Commit 353a9c2

Browse files
committed
Update README.md
1 parent 0d9f499 commit 353a9c2

File tree

1 file changed

+129
-2
lines changed

1 file changed

+129
-2
lines changed

README.md

Lines changed: 129 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,129 @@
1-
# O365-iOS-Connect
2-
This Connect sample for iOS shows how to connect your app to Office 365. Once connected, the sample shows how to send a simple service call.
1+
#Office 365 Connect app for iOS#
2+
3+
Connecting to Office 365 is the first step every iOS app must take to start working with the rich data and services Office 365 offers. This sample shows how to connect to Office 365 and call the sendMail API to send an email from your Office 365 mail account. You can use this sample as a starting point to quickly connect your iOS apps to Office 365.
4+
5+
**Table of contents**
6+
7+
* [Set up your environment](#set-up-your-environment)
8+
* [Use CocoaPods to import the O365 iOS SDK](#use-cocoapods-to-import-the-o365-ios-sdk)
9+
* [Register your app with Microsoft Azure](#register-your-app-with-microsoft-azure)
10+
* [Get the Client ID and Redirect Uri into the project](#get-the-client-id-and-redirect-uri-into-the-project)
11+
* [Code of Interest](#code-of-interest)
12+
* [Questions and comments](#questions-and-comments)
13+
* [Additional resources](#additional-resources)
14+
15+
16+
17+
## Set up your environment ##
18+
19+
To run the Office 365 Connect app for iOS, you need the following:
20+
21+
22+
* [Xcode](https://developer.apple.com/) from Apple.
23+
* An Office 365 account. You can get an Office 365 account by signing up for an [Office 365 Developer site](http://msdn.microsoft.com/en-us/library/office/fp179924.aspx). This will give you access to the APIs that you can use to create apps that target Office 365 data.
24+
* A Microsoft Azure tenant to register your application. Azure Active Directory provides identity services that applications use for authentication and authorization. A trial subscription can be acquired here: [Microsoft Azure](https://account.windowsazure.com/SignUp).
25+
26+
**Important**: You will also need to ensure your Azure subscription is bound to your Office 365 tenant. To do this see the Active Directory team's blog post, [Creating and Managing Multiple Windows Azure Active Directories](http://blogs.technet.com/b/ad/archive/2013/11/08/creating-and-managing-multiple-windows-azure-active-directories.aspx). The section **Adding a new directory** will explain how to do this. You can also read [Set up Azure Active Directory access for your Developer Site](http://msdn.microsoft.com/en-us/office/office365/howto/setup-development-environment#bk_CreateAzureSubscription) for more information.
27+
28+
29+
* Installation of [CocoaPods](https://cocoapods.org/) as a dependency manager. CocoaPods will allow you to pull the Office 365 and Azure Active Directory Authentication Library (ADAL) dependencies into the project.
30+
31+
Once you have an Office 365 account, an Azure AD account that is bound to your Office 365 Developer site, you'll need to perform the following steps:
32+
33+
1. Register your application with Microsoft Azure, and configure the appropriate Office 365 Exchange Online permissions. We'll show you how to do this later.
34+
2. Install and use CocoaPods to get the Office 365 and ADAL authentication dependencies into your project. We'll show you how to do this later.
35+
3. Enter the Azure app registration specifics (ClientID and RedirectUri) into the Office 365 Connect app.
36+
37+
## Use CocoaPods to import the O365 iOS SDK
38+
Note: If you've never used **CocoaPods** before as a dependency manager you'll have to install it prior to getting your Office 365 iOS SDK dependencies into your project. If you already have it installed you may skip this and move on to **Getting the Office 365 SDK for iOS dependencies in your project**.
39+
40+
Enter both these lines of code from the **Terminal** app on your Mac.
41+
42+
sudo gem install cocoapods
43+
pod setup
44+
45+
If the install and setup were successful, you should see the message **Setup completed in Terminal**. For more information on CocoaPods, and its usage, see [CocoaPods](https://cocoapods.org/).
46+
47+
48+
**Getting the Office 365 SDK for iOS dependencies in your project.**
49+
The O365 iOS Connect app already contains a podfile that will get the Office 365 and ADAL components (pods) into your project. It's located in the sample root ("Podfile"). The example shows the contents of the file.
50+
51+
target ‘test’ do
52+
pod 'ADALiOS', '~> 1.0.0' # 1.0.0 < ver < 1.1.0
53+
pod 'Office365/Outlook', '~> 0.8.3'
54+
pod 'Office365/Discovery', '~> 0.8.3'
55+
end
56+
57+
58+
You'll simply need need to navigate to the project directory in the **Terminal** (root of the project folder) and run the following command.
59+
60+
61+
pod install
62+
63+
Note: You should receive confirmation that these dependencies have been added to the project and that you must open the workspace instead of the project from now on in Xcode (**O365-iOS-Connect.xcworkspace**). If there is a syntax error in the Podfile, you will encounter an error when you run the install command.
64+
65+
## Register your app with Microsoft Azure
66+
1. Sign in to the [Azure Management Portal](https://manage.windowsazure.com), using your Azure AD credentials.
67+
2. Click **Active Directory** on the left menu, then click the directory for your Office 365 developer site.
68+
3. On the top menu, click **Applications**.
69+
4. Click **Add** from the bottom menu.
70+
5. On the **What do you want to do page**, click **Add an application my organization is developing**.
71+
6. On the **Tell us about your application** page, specify **O365-iOS-Connect** for the application name and select **NATIVE CLIENT APPLICATION** for type.
72+
7. Click the arrow icon on the lower-right corner of the page.
73+
8. On the Application information page, specify a Redirect URI, for this example, you can specify http://localhost/connect, and then click the check box in the lower-right hand corner of the page. Remember this value for the section **Getting the ClientID and RedirectUri into the project**.
74+
9. Once the application has been successfully added, you will be taken to the Quick Start page for the application. From here, click Configure in the top menu.
75+
10. Under **permissions to other applications**, add the following permission: **Add the Office 365 Exchange Online application**, and select **Send mail as a user** permission.
76+
13. Copy the value specified for **Client ID** on the **Configure** page. Remember this value for the section **Getting the ClientID and RedirectUri into the project**.
77+
14. Click **Save** in the bottom menu.
78+
79+
80+
## Get the Client ID and Redirect Uri into the project
81+
82+
Finally you'll need to add the Client ID and Redirect Uri you recorded from the previous section **Register your app with Microsoft Azure**.
83+
84+
Browse the **O365-iOS-Connect** project directory and open up the workspace (O365-iOS-Connect.xcworkspace). In the **AuthenticationManager.m** file you'll see that the **ClientID** and **RedirectUri** values can be added to the top of the file. Supply the necessary values here:
85+
86+
// You will set your application's clientId and redirect URI. You get
87+
// these when you register your application in Azure AD.
88+
static NSString * const REDIRECT_URL_STRING = @"ENTER_REDIRECT_URI_HERE";
89+
static NSString * const CLIENT_ID = @"ENTER_CLIENT_ID_HERE";
90+
static NSString * const AUTHORITY = @"https://login.microsoftonline.com/common";
91+
92+
93+
94+
95+
## Code of Interest
96+
97+
**Authentication with Azure AD**
98+
99+
The code for authenticating with Azure AD, which includes retrieval and management of your access tokens is located in the AuthenticationManager.m file.
100+
101+
102+
**Outlook Services Client**
103+
104+
The code for creating your Outlook Services client is located in the Office365ClientFetcher.m file. The code in this file creates the Outlook Services client object required for performing API calls against the Office 365 Exchange service. The client requests will leverage the authentication code to get the application an access and refresh token to act on behalf of the user. The access and refresh token will be cached. The next time a user attempts to access the service, the access token will be issued. If the access token has expired, the client will issue the refresh token to get a new access token.
105+
106+
107+
**Discovery Service**
108+
109+
The code for using the O365 Discovery service to retrieve the Exchange service endpoints/URLs is located in the internal method connectToOffice365 is called from the viewDidLoad method in the SendMailViewController.m file.
110+
111+
112+
**Office 365 SendMail snippet**
113+
114+
The code for the operation to send mail is located in the sendMailMessage method in the SendMailViewController.m files.
115+
116+
117+
118+
## Questions and comments
119+
120+
We'd love to get your input on this Office 365 iOS sample. You can send your feedback to us in the [Issues](https://github.com/OfficeDev/O365-iOS-Connect) section of this repository. <br>
121+
Questions about Office 365 development in general should be posted to [Stack Overflow](http://stackoverflow.com/questions/tagged/Office365+API). Make sure that your questions are tagged with [Office365] and [API].
122+
123+
## Additional resources
124+
125+
* [Office 365 APIs documentation](http://msdn.microsoft.com/office/office365/howto/platform-development-overview)
126+
* [File REST operations reference](http://msdn.microsoft.com/en-us/office/office365/api/files-rest-operations)
127+
* [Calendar REST operations reference](http://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations)
128+
* [Office Dev Center](http://dev.office.com/)
129+
* [Office 365 APIs Starter Project for Windows](https://github.com/OfficeDev/Office-365-APIs-Starter-Project-for-Windows)

0 commit comments

Comments
 (0)