- Version: 0.1.1
- GitHub:
- NPM: https://www.npmjs.com/package/nativescript-office365
- Downloads:
- Last Day: 0
- Last Week: 0
- Last Month: 0
Office 365 Graph API plugin for NativeScript
Manage Office 365 Users, Groups, Mail, Calendars, Contacts, Files, Tasks, People, Notes and more — all from a single endpoint
Note: iOS only, for now
Features
For readability the supported features have been moved to their own README's:
- Setup (continue reading below)
- Authentication
- Using via REST
- Using via MS Graph Client
Prerequisites
You should have an Office 365 Account admin account. If you don't have one yet, you can get a free trial here.
Register your mobile app here. This will require you to login with your Office 365 account. You can then click the big "Add an app" button and go through the steps listed there, starting with giving you app a name. On the app creation screen, you need to do 3 things:
- Click the "Add Platform" button and select "Mobile application"
- Copy the "Client Id" GUID from the Mobile Application section.
- Click "Save" at the bottom.
Setup
Add TypeScript to your NativeScript project if you don't already have it added. While this is not a requirement, it's highly recommended. If you want to watch a video on how to convert your existing JavaScript based NativeScript app to TypeScript, watch it here.
From the command prompt go to your app's root folder and execute:
tns plugin add nativescript-office365
Then open references.d.ts
in the root of your project and add this line to get autocompletion and type-checking for this plugin:
/// <reference path="./node_modules/nativescript-office365/office365.d.ts" />
Usage
If you want a quickstart, get the demo app here.
Start-up wiring
We need to do some wiring when your app starts, so open app.ts
and add this before application.start();
:
TypeScript
import * as o365 from 'nativescript-office365';
var o365InitOptions : o365.InitOptions = {
clientId: '<enter GUID here>', //client id for application (GUID)
scopes: ['Files.ReadWrite']
};
o365.init(o365InitOptions);
Note 1: Enter the client id GUID value that was generated for you when you registered your app in the Prerequisites section.
Note 2: The scope listed above gives your NativeScript app SharePoint (OneDrive) file read/write permissions. Add/replace with other scope strings to give your app permissions to do other activities. More scopes are listed here
Future work
- Add Android support
- Add support for automatic auth token refresh for REST
- Expose MS Graph Client to consumer
Credits
The starting point for this plugin was the NativeScript Plugin Seed by Nathan Walker. The MS Graph Client iOS version wouldn't have worked without the iOS ninja expertise of Jason Zhekov