Over the last few years, Microsoft has been working hard to woo the development community over to the Office 365 platform. Under the guidance of new CEO Satya Nadella, things are no longer “Microsoft only”. For every major mobile platform there are now SDK’s available for other Operating Systems such as iOS and Android as well as, of course, Windows Phone. These SDK’s make it very easy to create mobile applications for Office 365 and in this blog post I’ll give some useful practical tips how to create mobile apps using the Office 365 API.
There’s no single answer when it comes to the question “how do I develop my mobile app?” Like with any app development, you’ll have two different options when creating your Office 365 mobile app:
Both options have advantages and disadvantages. When specifically targeting a single platform, you are able to use all native capabilities of the mobile device on that platform. Performance will also be better, compared with, for example, a Cordova app. However, if you want to target multiple platforms, you’ll have to develop, test, and maintain different versions of your apps for the different platforms. It also requires different developer experience for each platform such as Java for Android and C# for Windows Phone.
On the other hand, targeting multiple platforms by using Cordova or Xamarin requires you to write the app only once, and allows you to deploy it to multiple platforms. It requires only knowledge of one development language like HTML5 and JavaScript in Cordova. However, this also comes with limitations: in Cordova everything runs inside a browser component, which has some restrictions around authentication with third party systems.
If you plan to only create an app for one mobile platform, go for the first option. Otherwise, investigate whether option two will suit your requirements since it will decrease development time and effort spent testing.
When developing a native application for Office 365, you will need the SDK’s for the platform of your choice first. See here for a starting point, it contains links to the Android, iOS and Windows SDK.
After that, have a look at these excellent starter projects and examples provided by Microsoft, targeting different SDK’s. Starter projects will give you a headstart when creating your mobile App, examples can be used to get a better understanding how to execute certain tasks. There is also a Virtual Academy Session available that gives some great examples for different scenarios and is a very good starting point.
When you decide to create a hybrid mobile app targeting multiple platforms, there is excellent documentation out there on how to do this. The Office 365 Starter projects and examples has a separate section for hybrid mobile apps. Cordova is gaining a lot of popularity in this space and is a good candidate to look into. Have a look at this example of how to create an Office 365 app with Angular and Cordova.
Suresh Jayabalan, Senior Program Manager at Microsoft, has written an excellent blog post about hybrid app development using Cordova. He talks about a very good example as well – have a look at Woodgroove that uses the Office 365 API to authenticate, query a user’s calendar appointments, and display them in the app. In a nutshell, the example code to do so, is outlined below:
var authContext = newO365Auth.Context(); authContext.getIdToken('https://outlook.office365.com/') .then(function(token) { // Promise callback: Authentication succeeded client = newExchange.Client( 'https://outlook.office365.com/ews/odata', token.getAccessTokenFn('https://outlook.office365.com') ); });
Using the constructed client object, you can then access all messages from the Inbox:
// Use getFolder to access Inbox folder client.me.folders.getFolder("Inbox").fetch() .then(function(folder) { // Retrieve all the messages folder.messages.getMessages().fetch() .then(function(mails) { // mails.currentPage contains all the mails in Inbox }); });
To get contacts, simply call getContacts:
client.me.contacts.getContacts().fetch() .then(function(contacts) { // contacts.currentPage contains the contacts information });
To support the developer community, experienced people within Microsoft have decided to create an open source repository with a lot of examples of how to do things in Office 365. Every example has the blessing of Microsoft and follows best practices. Have a look here for an overview, the GitHub repository can be found here. Some useful examples include samples for an e-mail app that allows reading of a user’s e-mail box or access a list including all its properties on a SharePoint site.
Development for Microsoft products like SharePoint and Office were always focused on development for Microsoft platforms; developing an app for Android or iOS that talked to SharePoint was always very hard to accomplish.
However, with the introduction of SDK’s for every major platform in the Office 365 developer suite, it’s now much easier to create mobile apps. Hybrid apps offer you even greater flexibility and allow you to deploy to multiple platforms with one single app. What’s more, it’s very easy!
Microsoft Partner Richard diZeraga explained that after creating an iOS app for Office 365, the hardest part was figuring out iOS development. However, accessing the Office 365 API’s worked like a charm! From where I’m standing, it seems that the Office 365 API’s have opened up a wide range of possibilities for mobile app development and this should open up a lot more opportunities for the development community.
Merken