25
Cross platform development with Azure Mobile Services Ibon Landa Plain Concepts

Cross platform development with azure mobile services

Embed Size (px)

DESCRIPTION

Cross platform development with azure mobile services

Citation preview

Page 1: Cross platform development with azure mobile services

Cross platform development with Azure Mobile ServicesIbon Landa

Plain Concepts

Page 2: Cross platform development with azure mobile services
Page 3: Cross platform development with azure mobile services
Page 4: Cross platform development with azure mobile services
Page 5: Cross platform development with azure mobile services

Mobile Platforms

iOS

Objective C

Xcode

Windows Phone

C#/Visual Basic/F#

Visual Studio

Android

Java

Eclipse

IntelliJ

Page 6: Cross platform development with azure mobile services
Page 7: Cross platform development with azure mobile services

What is Mobile Services?

Page 8: Cross platform development with azure mobile services
Page 9: Cross platform development with azure mobile services

The REST API

Action HTTP Verb URL Suffix

Create POST /TodoItem

Read GET /TodoItem?$filter=id%3D42

Update PATCH /TodoItem/id

Delete DELETE /TodoItem/id

https://Mobileservice.azure-mobile.net/tables/*

Page 10: Cross platform development with azure mobile services

Mobile Services Tiers

General Availability99.9%

Free Standard Premium

Usage Restrictions

Up to 10 services,Up to 500 Active Devices*

N/A N/A

API Calls 500K(per subscription)

1.5M(per unit)

15M(per unit)

Scale N/A Up to 6 Standard units

Up to 10 Enterprise units

Scheduled Jobs Limited Included Included

SQL Database(required)

20MB Included, Standard rates apply

for more capacity

20MB Included, Standard rates apply

for more capacity

20MB Included, Standard rates apply

for more capacity

Page 11: Cross platform development with azure mobile services
Page 12: Cross platform development with azure mobile services

Mobile push is everywhere

Reservation changes, Deals, Back-officeTravel/Hospitality/Airlines

SMS replacement, Deals, Back-officeBanking/Insurance

Orders, Product UX,

Back-officeDiscrete manufacturing/Auto

Prescriptions, Appointments,

LOB (maintenance)Healthcare

Breaking newsNews/Media

Offers, Orders, Back-officeRetail

Page 13: Cross platform development with azure mobile services

Registration at app launch1. Client app contacts Platform Notification Service, to retrieve

current channel (e.g. ChannelURIs, device tokens, registrationIds)

2. App updates handle in back-end

Sending Notification1. App back-end send notification to PNS

2. PNS pushes the notification to the app on the device

Maintenance1. Delete expired handles when PNS rejects them

Push notification lifecycle

Platform

Notification

Service

App back-end

Page 14: Cross platform development with azure mobile services

Platform dependencyDifferent communication protocols to PNS’ (e.g. HTTP vs TCP, xml payload vs json payload)

Different presentation formats and capabilities (tiles vs toasts vs badges)

RoutingPNS’ provide a way to send a message to a device/channel

Usually notifications are targeted at users or interest groups (e.g. employees assigned to a customer account)

App back-end has to maintain a registry associating device handles to interest groups/users

ScaleApp back-end has to store current handles for each device high storage and VM costs

Broadcast to millions of devices with low latency requires parallelization (DB ad VM)

Challenges of push notifications

Page 15: Cross platform development with azure mobile services

One-time set up1. Create a Notification Hub

Register1. The client app retrieves its current handle from the PNS

2. Client app creates (or updates) a registration on the Notification Hub with the current handle

Send Notification1. The app back-end sends a message to the Notification Hub

2. Notification Hub pushes it to the PNS’

Using Notification Hubs

APNs WNS

Notification Hub

App back-end

iOS app Windows app

MPNS

GCM

ADM

Page 16: Cross platform development with azure mobile services

X-plat: from any back-end to any mobile platformBackend can be on-prem or in the cloud, .NET/Node/Java/PHP/Node/anything.

Support Windows Phone/Windows/iOS/Android and (as of today) Kindle Fire.

No need to store device information in the app back-endNotification Hub maintains the registry of devices and the associations to users/interest groups

Routing and interest groupsTarget individual users and large interest groups using tags

Personalization and localizationKeep your back-end free of presentation concerns like localization and user preferences using templates

Broadcast at scale, multicast, unicastPush notifications to millions of devices (across platforms) with a single call

TelemetryRich telemetry available through portal or APIs

Advantages of using Notification Hubs

Page 17: Cross platform development with azure mobile services

Bing (news, finance, sports, …) Sochi 2014

Case studies

10s

3+ <2

100s

3+ 150+

Page 18: Cross platform development with azure mobile services

Register Send

Some snippets

await

[hub registerNativeWithDeviceToken:deviceTokentags:nilcompletion:^(NSError* error) { … }];

hub.register(regid);

var toast = @“<notification payload>";hub.SendWindowsNativeNotificationAsync(toast);

hubService.wns.sendToastText01(null, {

text1: 'Hello from Node!'},function (error)

{…

});

Page 19: Cross platform development with azure mobile services

Tags as interest groups1. Client app can register with a set of tags

2. Tags are simple strings (no pre-provisioning is required)

3. App back-end can target all clients with the same tag

You can use tags also forMultiple type of interest groups, e.g.

Follow bands: tag “followband:Beatles”

Follow users: tag “followuser:Alice”

Tag devices with a user id

Tags

Notification Hub

App back-end

Tag:”Beatles”Tag:”Wailers”

Tag:”Beatles”

Page 20: Cross platform development with azure mobile services

Register

Some snippets

await new string[] {"myTag", "myOtherTag"}

[hub registerNativeWithDeviceToken:deviceToken tags:@[@"myTag", @"myOtherTag"] completion:^(NSError* error) {…

}];

hub.register(regid, "myTag“, "myOtherTag");

Page 21: Cross platform development with azure mobile services

Notification Hubs is not a storage systemMaintain an authoritative store for your tags

In the deviceEvery platform provides apps a way to store user information locally or in the cloudE.g. Roaming settings, iCloud

In your app back-endUsually stored by userTry not to replicate device information

Register methods always overwrite tagsEach time you update the channel, overwrite all the tags

“How do I read tags from my hub?”

Page 22: Cross platform development with azure mobile services

RegistrationClient apps can register with a platform specific template, e.g.

Windows tablet registers with Windows Store ToastText01 template

iPhone with the Apple JSON template:{ aps: {alert: “$(message)”}}

Send notificationApp back-end sends a platform independent message: {message: “Hello!”}

NotesMultiple templates can be specified for each device

Each template can have a different set of tags

Using templates for multi-platform push

Notification Hub

App back-end

<toast><visual><binding template=\"ToastText01\"><text id=\"1\">$(message)</text>

</binding></visual>

</toast>

{aps: {

alert: “$(message)”}

}

{message: “Hello!”

}

Hello!

Hello!

Page 23: Cross platform development with azure mobile services

RegistrationClient apps can register with personalized templates, e.g.

Windows tablet wants to receive news in English

iPhone wants Italian

Send notificationApp back-end sends a message including both languages: {news_en: “Hello!”, news_it: “Ciao!”}

Template ExpressionsTemplates support a simple expression language:

E.g. {‘Elio, ’+$(friend)+’ added you to ’+$(groupName)}

Using templates for localization

Notification Hub

App back-end

<toast><visual><binding template=\"ToastText01\"><text id=\"1\">$(news_en)</text>

</binding></visual>

</toast>

{aps: {

alert: “$(news_it)”}

}

{news_en: “Hello!”,news_it: “Ciao!”

}

Hello!

Ciao!

Page 24: Cross platform development with azure mobile services
Page 25: Cross platform development with azure mobile services

Thanks!