New MS Open Tech SDKs Make it Easier to Connect Android and iOS Apps to Office 365 Services

A host of new tools released at TechEd Europe 2014 make it easier for Android and iOS developers to add Office services to their mobile apps, working with familiar tools they already know. The Office Dev blog has information about all of the releases, and today you can download the new Office 365 SDK for iOS as well as a production ready release of the Office 365 SDK for Android (previously available in a preview release).

For Android Studio developers, be sure to check out the MS Open Tech Tools plugin for IntelliJ and Android Studio released today. This plugin gives Android developers simple access to Office 365 services via the Android SDK, as well as Azure Mobile Services and push notifications, all from within the familiar IntelliJ or Android Studio development environment.

Our developers at MS Open Tech, in collaboration with the Office team, designed these mobile SDKs for native application development to enable seamless integration of Office 365 services and data with apps running on Android and iOS client platforms.

Android and iOS SDKs

These capabilities open up a new world of opportunities for developers, who can now easily integrate their offerings with 400 petabytes of data and popular Office 365 services.

The SDKs are modular, containing five independent packages:

  • Outlook Services provides CRUD operations for mail, calendar and contacts stored in Office 365 Exchange Online
  • Files Services provides access to files stored in Office 365 OneDrive for Business accounts and SharePoint Online sites
  • Directory Services for access to users, groups and their properties via the Azure AD Graph API
  • SharePoint Lists providing access to lists and list items stored in Office 365 SharePoint Online
  • Discovery Services help developers determine the base URL for various services

All of this functionality is provided by robust Office 365 REST APIs, which are exposed through the Android and iOS SDKs as well as other SDKs available for .NET and JavaScript/TypeScript developers.

In this blog post, we’re going to take a look at how the Android and iOS SDKs were built, what they offer to developers, and how you can quickly begin taking advantage of Office 365 services in your own apps. The discussion below covers the high-level architecture and general concepts, and then we’ve provided links to a variety of resources and code samples that you can use to jumpstart your development.

Building the SDKs

To take full advantage of the powerful capabilities offered by these SDKs, it’s helpful to understand how they were built, as well as the benefits provided by this approach.

The Office 365 REST APIs are based on OData and therefore include Common Schema Definition Language (CSDL) metadata documents that describe the entities exposed by each API. CSDL is a standardized XML representation of the entity data model exposed by an OData service. The Android and iOS SDKs (as well as other Office 365 SDKs) were generated from the CSDL files using a customized code-generation process:

generating the SDKs

 

This approach assures consistency across the SDKs (e.g., the same API surface area is exposed for all platforms) while also allowing for customization of each SDK to support the popular paradigms of the target language/platform.

For example, here are the Android and iOS code snippets to retrieve an email inbox using Outlook Services:

Android and iOS code samples

As you can see, these snippets are conceptually similar but each reflects the stylistic differences specific to Android and iOS development.

The underlying Office 365 REST APIs for Outlook Services, Directory Services, Files Services and Discovery Services are all compliant with OData 4.0. As a result the SDKs are able to include quite a bit of functionality “for free,” because developers can use system query options defined in the OData standard, such as $select, $expand, $filter and $skip.

To maximize extensibility and flexibility, the SDKs use an inversion of control design pattern based on a dependency resolver that you instantiate for each entity client you create. Here are examples of creating a default dependency resolver in Android or iOS code:

dependency resolver

Note that default implementations are provided as shown in the diagram above, making the dependency resolver ready for immediate use. You can override the default implementations if you have special requirements or want to use a different implementation.

Authentication and Authorization

Office 365 services are secure, and your app needs to obtain permission from the user to gain secure delegated access to their private data stored in the cloud.

You will first need to register your app in Azure AD as a native client app, and obtain a Client ID for it. (Note that if you're using the MS Open Tech Tools plugin, it will automatically create the App principal in AAD for you.) Then you’ll use the Azure Active Directory Authentication Library (ADAL) available for your client platform to handle authentication (who is the user?), authorization (what services do they have access to?) and consent (does the user agree to provide your app with access?). The result of this process will be an OAuth 2.0 access token that your app can use to gain access to Office 365 services.

The Android and iOS SDKs use the same consistent approach to authentication and authorization employed by other Office 365 SDKs. At a high level, here’s what you need to do at app startup to give the user access to their Office 365 data:

authentication workflow

This workflow provides the consistent and straightforward user experience that people have come to expect from mobile apps: the app asks for permission to work with the user’s secured data and services, then stores an access token (managed securely via ADAL) that can be used for subsequent API calls.

Office 365 SDK for iOS

Office 365 SDK for iOS

The Office 365 SDK for iOS is available from the OfficeDev repo on GitHub, or you can use the Cocoapods dependency manager to include it as a dependency in your XCode or JetBrains AppCode project.

For authentication, iOS developers should use ADALiOS (the open-source ADAL library for Objective-C). As with the iOS SDK, ADALiOS is available from GitHub or via Cocoapods.

Office 365 SDK for Android

Office 365 SDK for Android

The Office 365 SDK for Android is a new production ready release that supersedes the preview version released in March of this year. You can get it from the GitHub repo, or using Gradle from Bintray's JCenter repo, the default central repo for Android Studio. You can clone the GitHub repo to install as source code, include the binary packages via Gradle scripts from JCenter, or just drop the JAR and AAR files in your project’s libs folder.

If you’d prefer to use Gradle to automatically include the Office 365 SDK for Android as a dependency in your Android Studio project, you’ll need this line in your project-level Gradle build script:

repositories {
  jcenter()
}

NOTE: the above line will be included by default in new Android Studio projects.

Then you can add the specific Office 365 SDK dependencies in module-level (app) build scripts as follows:

dependencies {
  // base OData stuff:
  compile group: 'com.microsoft.services', name: 'odata-engine-interfaces', version: '(,1.0)'
  compile group: 'com.microsoft.services', name: 'odata-engine-java-impl', version: '(,1.0)'
  compile group: 'com.microsoft.services', name: 'odata-engine-helpers', version: '(,1.0)'
  compile group: 'com.microsoft.services', name: 'odata-engine-android-impl', version: '(,1.0)'
  // choose the services/SDKs you need:
  compile group: 'com.microsoft.services', name: 'outlook-services', version: '(,1.0)'
  compile group: 'com.microsoft.services', name: 'discovery-services', version: '(,1.0)'
  compile group: 'com.microsoft.services', name: 'directory-services', version: '(,1.0)'
  compile group: 'com.microsoft.services', name: 'file-services', version: '(,1.0)'
  compile group: 'com.microsoft.services', name: 'list-services', version: '(,1.0)'
}

We’ll also be publishing the Office 365 SDK for Android to the Maven Central repo soon.

Android developers can find the open source Android ADAL library on GitHub, and Android Studio will use Gradle to automatically download the ADAL binaries and add them to your project if you add this line to your Gradle script:

compile 'com.microsoft.aad:adal:1.0.2'

Resources

With these tools, it is now possible for Android and iOS developers to easily build apps that take advantage of Office 365 services. A variety of resources have been published today to help you get started, and more will be available in the days and weeks ahead. Below are links to places to find code samples, documentation, and more.

The Office Dev Center has a rich set of resources to help you learn the Office 365 APIs and take advantage of them in projects on any platform:

Office 365 SDK for Android – GitHub repo. Here you’ll find:

  • Quickstart app – step by step instructions for creating an Android app that retrieves messages from Exchange
  • A complete simple sample app that retrieves messages and calendar events
  • Tests (providing examples of how to use various SDK functionality)
  • Information about how to contribute to MS Open Tech open source projects.

Office 365 SDK for iOS – GitHub repo. Here you’ll find:

  • Instructions for using the SDK with Xcode and Cocoapods.
  • Sample code for Outlook Services, Files Services and Discovery Services. (more to come soon)
  • Information about how to contribute to MS Open Tech open source projects.

Other resources:

Many other resources are coming online soon, and we’ll update this list as they become available.

We’re looking forward to continuing our work to make Microsoft services available to developers on any popular device or operating system, using the tools and technologies you already know and love! If you have questions about use of the Android or iOS SDKs for Office 365, please let us know in the comment thread below.

Josh Gavant, Senior Program Manager
Lorenzo Tessiore, Principal Development Lead
Doug Mahugh, Senior Technical Evangelist
Microsoft Open Technologies, Inc.

 


16 thoughts on “New MS Open Tech SDKs Make it Easier to Connect Android and iOS Apps to Office 365 Services

  1. Pingback: Anonymous

  2. Pingback: Microsoft announces new SDKs for Android and iOS, teams up with IFTTT, others | iGot iPhones

  3. Pingback: Microsoft announces new SDKs for Android and iOS, teams up with IFTTT, others - TheApplePips.com

  4. Pingback: Microsoft announces new SDKs for Android and iOS, teams up with IFTTT, others | Smartphone Tips n Tricks

  5. Pingback: Microsoft announces new SDKs for Android and iOS, teams up with IFTTT, others | Tablet News

  6. Pingback: Microsoft launches iOS developer tools for deep integration with Office 365 features and services | Xeno institute

  7. Pingback: Microsoft launches iOS developer tools for deep integration with Office 365 features and services - TheApplePips.com

  8. Pingback: Microsoft unveils new Office 365 APIs and SDKs for iOS and Android - 196ys

  9. Pingback: Nye Office 365-muligheter for utviklere | Datamaskin

  10. Pingback: TechEd Europe 2014: New APIs and SDKs for Office 365 app development | Blog

  11. Pingback: TechEd recap day 3: the one with the Country Drinks, Office and SharePoint development & a bit of Azure - Microsoft Developer Network (MSDN) Belux Team Blog - Site Home - MSDN Blogs

  12. Pingback: Programming Office 365: Hands On with Microsoft's new APIs - Techbait Tech News

  13. Pingback: Programming Office 365: Hands On with Microsoft's new APIs | Van JaVa

  14. Pingback: New Office 365 extensibility for Windows, iOS, Android and web developers | Gadget Geek

  15. Pingback: https://bft.usu.edu/9tlm9

  16. Pingback: Developing Native iOS Apps using the Office 365 SDK for iOS - Richard diZerega's Blog - Site Home - MSDN Blogs