azure notification hub

26
Template designed by Azure Notification Hub Luca Di Fino [email protected] @luke2375 luke2375.wordpress.com

Upload: dotnetcampus

Post on 15-Aug-2015

32 views

Category:

Education


4 download

TRANSCRIPT

Page 1: AZURE NOTIFICATION HUB

Template designed by

Azure Notification HubLuca Di Fino

[email protected]

@luke2375

luke2375.wordpress.com

Page 2: AZURE NOTIFICATION HUB

http://www.key2.it/

Sviluppatore Windows / Windows Phone

Analisi, Progettazione, Sviluppo

Eventi

chi sono

#NotificationHub #dotnetcampus @luke2375 @dotnecampus   

Page 3: AZURE NOTIFICATION HUB

OverviewAzure Notification HubLet’s start

• Hub• App• Push

Something more• More notifications• More channels• More apps

Q&A

agenda

Page 4: AZURE NOTIFICATION HUB

Overview

Push Notifications offer developers a way to send timely information relating to their applications even when they are not running

Push notifications are delivered through platform-specific infrastructures called Platform Notification Systems (PNS)

+Windows has the unique ability to provide the end user glanceable access to the information they care most about, via Live Tiles

Back-end

PNS

Device

1

2

3

4

Retrieve PNS Handle

Store PNS Handle

Send Notification

Send to Device

Page 5: AZURE NOTIFICATION HUB

Critical points

• Users management

• Scale• Refresh handles

• Multicast

• Platform dependency

• Routing

• Monitor and telemetry

Page 6: AZURE NOTIFICATION HUB

A lot of time spent in topics unrelated to the main business logic of the app !!!

Page 7: AZURE NOTIFICATION HUB

Azure Notification Hub

Page 8: AZURE NOTIFICATION HUB

Azure Notification Hub

• Device token management

• Multiple platforms

• Scale

• Works with any backend• .NET, Node.JS, REST API, PHP, Java, etc.

• Efficient tag-based multicast and pub/sub routing

• Personalization

• Rich telemetry

Page 10: AZURE NOTIFICATION HUB

dem

o

+

Page 11: AZURE NOTIFICATION HUB

1. Create the notification hub – Azure

2. Get app SID and Secret – Dev Center (Windows or Windows Phone)

3. Configure hub

4. Create client app – Visual Studio

5. Create app backend

Demo walk-through

Page 12: AZURE NOTIFICATION HUB

Create the Notification Hub

Page 13: AZURE NOTIFICATION HUB

Get app SID and Secret (Windows)

1

2

Page 14: AZURE NOTIFICATION HUB

Get app SID and Secret (Windows Phone)

1

2

Page 15: AZURE NOTIFICATION HUB

Get app SID and Secret

SID

Secret

Page 16: AZURE NOTIFICATION HUB

Configure the Notification Hub

Page 17: AZURE NOTIFICATION HUB

• Add Nuget package WindowsAzure.Messaging.Managed

• Set Toast capable in .appxmanifest

• Create and register Notification Channel in app.xaml.cs

Configure the app (WinRT)

string notificationHubPath = NOME_HUB;string connectionString = DefaultListenSharedAccessSignature;

hub = new NotificationHub(notificationHubPath, connectionString);var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();await hub.RegisterNativeAsync(channel.Uri);

Page 18: AZURE NOTIFICATION HUB

• Add Nuget package WindowsAzure.ServiceBus

• Create the hub

• Send native notifications

Configure the backend

private NotificationHubClient hub; hub = NotificationHubClient.CreateClientFromConnectionString(endpoint, hubname);

await hub.SendWindowsNativeNotificationAsync(XMLpayload); //WinRTawait hub.SendMpnsNativeNotificationAsync(XMLpayolad); //Silverlightawait hub.SendAppleNativeNotificationAsync(JSONpayload); //iOSawait hub.SendGcmNativeNotificationAsync(JSONpayload); //Android

Page 19: AZURE NOTIFICATION HUB

More notifications (toast)

ToastText01 ToastImageAndText01

Page 20: AZURE NOTIFICATION HUB

More notifications (tile)

TileSquareImage/TileSquare150x150Image

TileSquarePeekImageAndText02

Page 21: AZURE NOTIFICATION HUB

What if we want more granular control over notifications?

If we want to push notifications only to people who are subscribed to a specific category, we use tags.

App

Backend

Combine tags with AND (&&), OR (||), NOT (!) and parentheses. Tag expressions are limited to 20 tags if they contain only ORs; otherwise they are limited to 6 tags

More channels

string[] tagsToSubscribeTo = { "phone", "news" };await hub.RegisterNativeAsync(channel.Uri, tagsToSubscribeTo);

await hub.SendWindowsNativeNotificationAsync(toast, "phone");await hub.SendWindowsNativeNotificationAsync(toast, "phone && news");await hub.SendWindowsNativeNotificationAsync(toast, "phone || news");

Page 22: AZURE NOTIFICATION HUB

Be polite! Let users disable notifications.

Or they will disable you (your app) ;-)

Page 23: AZURE NOTIFICATION HUB

Unregister notifications

var registration = await hub.RegisterNativeAsync(channel.Uri, tagsToSubscribeTo);

await hub.UnregisterAsync(registration);

await hub.UnregisterNativeAsync();

await hub.UnregisterAllAsync(channel.Uri);

Page 25: AZURE NOTIFICATION HUB
Page 26: AZURE NOTIFICATION HUB

Grazie a tutti per la partecipazione

Riceverete il link per il download a slide e demo via email nei prossimi giorni

Per contattarmi

Grazie e Q&A

Luca Di Fino

[email protected]

@luke2375

luke2375.wordpress.com

#NotificationHub #dotnetcampus @luke2375 @dotnecampus