azure notification hub
TRANSCRIPT
Template designed by
Azure Notification HubLuca Di Fino
@luke2375
luke2375.wordpress.com
http://www.key2.it/
Sviluppatore Windows / Windows Phone
Analisi, Progettazione, Sviluppo
Eventi
chi sono
#NotificationHub #dotnetcampus @luke2375 @dotnecampus
OverviewAzure Notification HubLet’s start
• Hub• App• Push
Something more• More notifications• More channels• More apps
Q&A
agenda
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
Critical points
• Users management
• Scale• Refresh handles
• Multicast
• Platform dependency
• Routing
• Monitor and telemetry
A lot of time spent in topics unrelated to the main business logic of the app !!!
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
Prices
http://azure.microsoft.com/en-us/pricing/details/notification-hubs/
dem
o
+
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
Create the Notification Hub
Get app SID and Secret (Windows)
1
2
Get app SID and Secret (Windows Phone)
1
2
Get app SID and Secret
SID
Secret
Configure the 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);
• 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
More notifications (toast)
ToastText01 ToastImageAndText01
More notifications (tile)
TileSquareImage/TileSquare150x150Image
TileSquarePeekImageAndText02
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");
Be polite! Let users disable notifications.
Or they will disable you (your app) ;-)
Unregister notifications
var registration = await hub.RegisterNativeAsync(channel.Uri, tagsToSubscribeTo);
await hub.UnregisterAsync(registration);
await hub.UnregisterNativeAsync();
await hub.UnregisterAllAsync(channel.Uri);
Notification Hub
Azure
MSDN
Windows Store (WinRT) tutorial
Windows Phone (Silverlight) tutorial
Android tutorial
iOS tutorial
Kindle tutorial
Windows toast and tile template catalogs
Toast template catalog
Tile template catalog
Resources
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
@luke2375
luke2375.wordpress.com
#NotificationHub #dotnetcampus @luke2375 @dotnecampus