44
Cloud Integration Developer’s Guide to Windows 10

Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Embed Size (px)

Citation preview

Page 1: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Cloud IntegrationDeveloper’s Guide to Windows 10

Page 2: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

AgendaConnected Mobile ExperiencesRoaming DataSharing State using OneDriveAzure Mobile AppsCreating an Azure Mobile Apps ServiceOffline syncPush Notifications

Page 3: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Evolution of Mobile Experiences

Reaching your customers in new and unique ways

Mobile “Devices” led to revolutionary Experiences

“Bring the experience with you”

Came with many constraints (small screen, battery, etc.)

Page 4: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Mobile Experiences - not just mobile devices

User is the center of the experience, not the device.

Available on the right device at the right time

Input model optimized for the experience.

Enabling Mobile Experiences with Universal Apps

The Experience you want on the device you want

User

Page 5: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Create shared mobile experiences whatever the device

Page 6: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Roaming Data APIs

Page 7: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Using the Roaming settingsThe RoamingSettings are exposed as a dictionary into which an application can save data

Note: On Windows Desktop, there is a special HighPriority key. This has no effect on Windows Mobile.

Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;

roamingSettings.Values["userName"] = name.Text;

var composite = new Windows.Storage.ApplicationDataCompositeValue(); composite["intVal"] = 1; composite["strVal"] = "string"; roamingSettings.Values["exampleCompositeSetting"] = composite;

Page 8: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Reading the Roaming settingsQuery the roaming settings by using the key nameWindows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;

if (roamingSettings.Values.ContainsKey("userName")){ name.Text = roamingSettings.Values["userName"].ToString();}

Page 9: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Roaming FolderUse the roaming app data store to read/write files and folders

Page 10: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

DataChanged notificationThe DataChanged event fires when the roaming data has changed

Windows.Storage.ApplicationData.Current.DataChanged += Current_DataChanged;...

void Current_DataChanged(ApplicationData sender, object args){ // Refresh your settings...}

The event only fires if the application is active You should still load up all your data when your app starts

Page 11: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Debugging apps using Roaming DataDevelopers can install an application on multiple unlocked devicesLocking a developer device will trigger the synchronisation If you have problems:Make sure that files are closed correctlyMake sure that the devices are running the same version of the application

Page 12: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Demo: Roaming Data

Page 13: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Tips on using roaming dataUse roaming folder and roaming settings in the same way as local folder and settingsHighPriority setting is available on Windows Desktop for quick sync, but has no effect on Windows Mobile

Good for app customisation settings, most recent activity, partially completed workSynchronisation stops if roaming data > 100KBBad for synchronising large amounts of data or “instant syncing” scenariosLast writer winsData deleted from cloud if app not used for “a period of time” (~30 days)

Page 14: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Do not use Roaming Data as a general purpose data syncing mechanism

Page 15: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Credential Lockersecurely store and roam user credentials

Page 16: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

OverviewAPIs to store credentials (user name, password) securelyWindows.Security.Credentials

Benefits:Secure storageCredential isolationRoaming

Page 17: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

RoamingCredentials roam across trusted devicesUses public or business cloud according to primary user identity

MSA

App

AAD

App

Page 18: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Credential Locker sample

void SaveCredential(string username, string password){ PasswordVault vault = new PasswordVault(); PasswordCredential cred = new PasswordCredential("MyAppResource", username, password); vault.Add(cred);}

IReadOnlyList<PasswordCredential> RetrieveCredential(string resource){ PasswordVault vault = new PasswordVault(); return vault.FindAllByResource(resource);}

Page 19: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Sharing State using OneDrive

Page 20: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

OneDrive Cloud StorageOneDriveAccessible cloud storage for personal documents, photos, and files that can be accessed from anywhere.Best for user owned content.

OneDrive for BusinessSecure enterprise grade storage for business documents and files.Best for business / enterprise owned content.

Depending on your app targeting both is appropriate.

Page 21: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

OneDrive Integration choices

Pickers and savers for quick integrations.Quickly open files from OneDrive and save files back.Supported for JavaScript, iOS, Android, and Windows Universal apps.

Two pathways to light up OneDrive<->app integration

More information: //BUILD/ session 3-734New OneDrive APIs for Developing Against OneDrive AND OneDrive for Business

http://channel9.msdn.com/Events/Build/2015/3-734

OneDrive API for deeper / robust integrations.Rich web API that enables all integrations with OneDrive.First party applications built on this.

Page 22: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Demo: OneDrive File Access

Page 23: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Azure App ServiceMobile Apps

Page 24: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

App Service: one integrated offering

API AppsEasily build and

consume APIs in the cloud

Web AppsWeb apps that scale with your business

Mobile AppsBuild Mobile apps

for any device

LOGIC AppsAutomate business

process across SaaS and on-premises

Page 25: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

App Service Platform View (Runtime)

API Apps

Web Apps

Mobile Apps

LOGIC Apps

Page 26: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

App ServiceCreate web and mobile experiences that share data access and business logicAutomate business processes with logic appsBuild custom APIs or consume connectors from MarketplaceOne common billing model for all of your App Services

Use a common Gateway to authenticate

Page 27: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Demo:Creating an Azure Mobile App

Page 28: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Mobile Apps Dynamic Schema

Very easy to configure backend data tables!

Create new table in backend store

Post Json from clientTable auto-configured with columns, plus sync tracking columns

Page 29: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Azure MobileOffline data sync

Page 30: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

The best mobile apps handle network interruptions gracefully

Page 31: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Adding offline sync to an app is usually hard.

With Azure Mobile App, it’s easy.

Page 32: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Why use mobile offline sync?Improve app responsiveness by caching server data locally on the deviceMake apps resilient against intermittent network connectivity Allow end-users to create and modify data even when there is no network accessSync data across multiple devices Detect and handle conflicts when the same record is modified by more than one client

Page 33: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

How it worksAccess data from Mobile Services tables even when app is offlineKeep a local queue of Create, Update, Delete operations and synchronize with server when app is back onlineDetect conflicts when same item is changed both locally and on serverUse soft delete to remove deleted records from client data storesCan use push notifications to trigger client sync

Page 34: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Demo:Azure Mobile App Offline Sync

Page 35: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Handle client sync conflicts

ClientConflict resolution

ServerConflict resolution

Page 36: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

▲, 1■, 2

▲, 1

▲, 1

●, 2

■, 2

Detect Conflicts with Optimistic Concurrency

Device 1Server

Device 2

▲, 1 ▲, 1

▲, 1 ▲, 1

▲, 1

■, 2

▲, 1

Create

Fetch

Update

Update

■, 2 ✘

Page 37: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Summary: Azure Mobile offline syncSupports both “primarily online” and “occasionally connected” scenariosExplicit push and pull leaves control to the developer

Works with a variety of server data storesSQL, Azure Tables, Mongo, Dynamics CRM, Salesforce, etc.

Cross-platform client SDKsWindows Universal, Xamarin, iOS, Android

Flexible and powerfulSupports custom local storage layersDetect and handle conflicts on server or client

Page 38: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Adding push notifications

Page 39: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Push Notifications 101Register device handle at app launch1. Client app retrieves handle from Platform Notification

Service (PNS)2. Client app sends handle to your custom backend

Send Notification3. Your backend connects to PNS and requests push

Your code has to manage scaleYour code has to map between logical users and device handles

4. PNS pushes notification to device

Maintain backend device handles5. Your code must delete expired handles when PNS

rejects them6. Your code must map between logical users and

device handles

PlatformNotification

Service

App back-end

Client app

1

23

4

5

6

Page 40: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Azure Notification HubsRegister device handle at app launch1. Client app retrieves handle from Platform Notification

Service2. Client sends handle to your backend

Backend registers with Notification Hub using tags to represent logical users and groups

Send Notification3. Backend sends request to Notification Hub using a tag

Notification Hub manages scaleNotification Hub maps logical users/groups to device handles

4. Notification Hub delivers notifications to matching devices

Maintain backend device handles5. Notification Hub deletes expired handles when PNS

rejects6. Notification Hub maintains mapping between logical

users/groups and device handles

PNS

App back-end

Client app

1

2

2

4

5

6

NotificationHub

3

4

Page 41: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Demo: Push Notifications

Page 42: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

Try it nowTry Azure Mobile App for free!No credit card required!Go to aka.ms/TryMobileApp

Learn moreGo to aka.ms/AppServiceMobile

Tweet @azuremobile

Page 43: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

ReviewConnected Mobile ExperiencesRoaming DataSharing State using OneDriveAzure Mobile AppsCreating an Azure Mobile Apps ServiceOffline syncPush Notifications

Page 44: Reaching your customers in new and unique ways Mobile “Devices” led to revolutionary Experiences “Bring the experience with you” Came with many constraints

© 2015 Microsoft Corporation. All rights reserved.