Azure notification hubs

Post on 08-Jan-2017

970 views 2 download

Transcript of Azure notification hubs

Prabath Fonseka (MVP)CTOOcculem

Microsoft Azure Notification Hub

Dinusha Kumarasiri (MVP)Software ArchitectOcculem

Agenda• Notifications in multiple platforms• Push notifications• Notification hubs• Sample App• Tags• Templates

Notifications in multiple platforms

Notifications in multiple platforms• Windows WNS• Toast• Tile• Badge• Raw

• Windows Phone (MPNS)• Toast• Tile• Raw

• Apple• Google• Amazon

Push Notifications

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

Use Cases

Push Notifications• Client app contacts Platform Notification

Service, to retrieve current channel (for example: ChannelURIs, device tokens, registrationIds)

• App updates handle in back-end

Registration at app launch

• App back-end send notification to PNS• PNS pushes the notification to the app on

the deviceSending

Notification

• Delete expired handles when PNS rejects themMaintenance

PlatformNotification

Service

App back-end

Push notification lifecycle

Push NotificationsBenefits

For enterprise appsKeep users up to date

Not only for alerts‘push to sync’ notifications

For consumer appsRicher than SMSConsiderably cheaper

Push NotificationsLimitations

• Different communication protocols to PNS• Different presentation formats and capabilities

Platform dependency

• Provide a way to send a message to a device/channel • Target user or group of interest • Back-end has to maintain an identification repository

Routing

• Need to store current handles for each device• Broadcast to millions of devices with low latency

Scale

Notification Hubs

Notification Hub

MPNS

Apple

GCM

Your

application

Notification HubsMessage DistributionPush notification to millions of devices across supported platforms with single call

Collect information from devices (e.g. location)

Message TemplatingConvert message in to appropriate format

• XML or JSONUse for localizationTemplates can be used to present certain information according to user preferences

Device RegistrationMaintains a registry of devices and users/groups

Message TargetingTargets specific users and groups based on tags Allows you to target messages to specific users

Notification HubsBing (news, finance, sports, …) Past event sample – Sochi 2014

Preinstalled on Windows

Millions of devices

Millions of notifications/day

Minutes to delivery

Interest groups(countries, disciplines, athletes)

Localized notifications

Million devices(iOS, Android, WP)

Million notifications

10s

3+ <2

100s

3+ 150+

Notification HubsLifecycle

APNsWNS

Notification Hub

App back-end

iOS app Windows app

MPNS

GCM

ADM

Notification HubsBenefits

X-plat: from any back-end

to any mobile

platform

No need to store device

information in the

app back-end

Routing and

interest groups

Personalization and

localization

Broadcast at

scale, multicast, unicast

Telemetry

Notification Hubs – Sample AppWindows 10 to Send/Receive Notifications

Step 4• I

n Visual Studio, add WindowsAzure.Messaging.Managed nuget package. Develop your app.

Notification Hubs – Sample App1. Register your device at application startup

Notification Hubs – Sample App2. Send a notification from your back-end:

Notification Hubs – Sample AppCode Snippets

Register Send

Windows / Windows Phoneawait hub.RegisterNativeAsync(channel.Uri);

iOS[hub registerNativeWithDeviceToken:deviceToken

tags:nilcompletion:^(NSError* error)

{ … }];Android / Kindlehub.register(regid);

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

Node / Mobile ServiceshubService.wns.sendToastText01(null, { text1: 'Hello from Node!' }, function (error) { … });

Notification Hubs – Sample AppPayload Snippets

Windows / Windows Phone<toast><visual><binding template="ToastText01"><text id="1">Hello from a .NET App!</text></binding></visual></toast>

iOS{"aps":{"alert":"Hello from .NET!"}}

Android{"data":{"message":"Hello from .NET!"}}

Notification Hubs – Sample AppExample : Payload for windows 10

• Adaptive and interactive toast notification• New Features like

o Actionso Input (Text, Dropdown)o Sounds

Notification Hubs – Sample AppExample : Payload for windows 10

Notification Payload for a Windows 10 device (generic template)<toast launch="1"><visual><binding template="ToastGeneric"><image id="1" src="Assets\Square30x30Logo.png" alt=""/><text id="1">Dear Bill Gates Get 40% if you come visit us today ! Best Regards from our team.</text></binding></visual><actions> <action activationType="foreground" content="Yes I will !" arguments="details"/> <action activationType="background" content="No thanks." arguments="later"/> </actions></toast>

Notification Hubs – TagsTags as interest groups• Client app can register with a set of tags• Tags are simple strings (no pre-

provisioning is required)• App back-end can target all clients with

the same tagYou can use tags also for:• Multiple type of interest groups, for

example: • Follow bands: tag “followband:Beatles”• Follow users: tag “followuser:Alice”

• Tag devices with a user ID • Tags can be user preferences or system

information

Notification Hub

App back-end

Tag:”Beatles”Tag:”Wailers”

Tag:”Beatles”

Notification Hubs – TagsRegister

Windows / Windows Phoneawait hub.RegisterNativeAsync(channel.Uri, new string[] {"myTag", "myOtherTag"});

iOS[hub registerNativeWithDeviceToken:deviceToken tags:@[@"myTag", @"myOtherTag"] completion:

^(NSError* error) {…

}];

Android / Kindlehub.register(regid, "myTag“, "myOtherTag");

Notification Hubs – TagsSend

Example:SendNotificationAsync(parameters, “(A && !B) || C”);

•“All my group except me”group:id && !user:idSocial

•Touchdown event is send to everybody following either teamFollowteam:A || Followteam:B || followplayer:1 || followplayer:2 …Events

•Send notifications at specific times. E.g. Tag with timezone, @12pm in Seattle send:timezone:PST && follows:thaifood

Hours

•Send a reminder to update to your first Android app version:version:1.0 && platform:AndroidVersions & platforms

Notification Hubs – TemplatesTemplates for multi-platform pushRegistration• Client apps can register with a platform

specific template, for example: • Windows tablet registers with Windows Store

ToastText01 template• iPhone with the Apple JSON template: { aps:

{ alert: “$(message)” } }Send notification• App back-end sends a platform independent

message: {message: “Hello!”}Notes• Multiple templates can be specified for each

device• Each template can have a different set of tags

Notification HubApp back-

end

<toast><visual>

<binding template=\"ToastText01\">

<text id=\"1\">$(message)</text>

</binding>

</visual></toast>

{aps: {

alert: “$(message)”

}}

{message:

“Hello!”}

Hello!

Hello!

Notification Hubs – TemplatesTemplates for localizationRegistration• Client apps can register with personalized

templates, for example: • Windows tablet wants to receive news in English • iPhone wants Italian

Send notification• App back-end sends a message including both

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

Template Expressions• Templates support a simple expression language:• For example: {‘Elio, ’+$(friend)+’ added you to

’+$(groupName)}

Notification HubApp 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!

Q & A

Thank You

Visit azure.microsoft.com for updated content and news