Azure
Notification Hub
Luca Di Fino
dev.luke2375@live.it
@luke2375
luke2375.wordpress.com
MICROSOFT MOBILE CAMP
ROMA, 12 Febbraio 2015
Agenda
• Overview
• Azure Notification Hub
• Let’s start
• Hub
• App
• Push
• Something more
• More notifications
• More channels
• More apps
• Q&A
MOBILE CAMP
ROMA, 12 Febbraio 2015
• 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
MOBILE CAMP
ROMA, 12 Febbraio 2015
3
Back-end
PNS
Device
1
2
3
4
Retrieve PNS Handle
Store PNS Handle
Send Notification
Send to Device
• Users management
• Platform dependency
• Scale
• Refresh handles
• Multicast
• Routing
• Monitor and
telemetry
MOBILE CAMP
ROMA, 12 Febbraio 2015
4
MOBILE CAMP
ROMA, 12 Febbraio 2015
5
Azure
Notification Hub
MOBILE CAMP
ROMA, 12 Febbraio 2015
6
• 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
MOBILE CAMP
ROMA, 12 Febbraio 2015
MOBILE CAMP
ROMA, 12 Febbraio 2015
8
Demo
MOBILE CAMP
ROMA, 12 Febbraio 2015
9
+
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
MOBILE CAMP
ROMA, 12 Febbraio 2015
MOBILE CAMP
ROMA, 12 Febbraio 2015
11
MOBILE CAMP
ROMA, 12 Febbraio 2015
12
1
2
MOBILE CAMP
ROMA, 12 Febbraio 2015
13
1
2
MOBILE CAMP
ROMA, 12 Febbraio 2015
14
SID
Secret
MOBILE CAMP
ROMA, 12 Febbraio 2015
15
MOBILE CAMP
ROMA, 12 Febbraio 2015
16
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.Messaging.Managed
• Set Toast capable in .appxmanifest
• Create and register Notification
Channel in app.xaml.cs
• Add Nuget package WindowsAzure.ServiceBus
• Create the hub
• Send native notifications
MOBILE CAMP
ROMA, 12 Febbraio 2015
17
private NotificationHubClient hub;
hub = NotificationHubClient.CreateClientFromConnectionString(endpoint, hubname);
await hub.SendWindowsNativeNotificationAsync(XMLpayload); //WinRT
await hub.SendMpnsNativeNotificationAsync(XMLpayolad); //Silverlight
await hub.SendAppleNativeNotificationAsync(JSONpayload); //iOS
await hub.SendGcmNativeNotificationAsync(JSONpayload); //Android
MOBILE CAMP
ROMA, 12 Febbraio 2015
18
ToastText01 ToastImageAndText01
MOBILE CAMP
ROMA, 12 Febbraio 2015
19
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
MOBILE CAMP
ROMA, 12 Febbraio 2015
20
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");
• When in Standard tier, Notification Hubs supports a feature that
enables you to schedule notifications up to 7 days in the future
• To cancel a scheduled notification
There are no limits on the number of scheduled notifications you can send
MOBILE CAMP
ROMA, 12 Febbraio 2015
21
Notification notification = new AppleNotification("{"aps":{"alert":"Happy birthday!"}}");
var scheduled = await hub.ScheduleNotificationAsync(notification, new DateTime(2014, 7, 19, 0, 0, 0));
await hub.CancelNotificationAsync(scheduled.ScheduledNotificationId);
MOBILE CAMP
ROMA, 12 Febbraio 2015
22
MOBILE CAMP
ROMA, 12 Febbraio 2015
23
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
MOBILE CAMP
ROMA, 12 Febbraio 2015
24
MOBILE CAMP
ROMA, 12 Febbraio 2015
25
Q&A
MOBILE CAMP
ROMA, 12 Febbraio 2015
26
Feedback form

Azure Notification hub

  • 1.
    Azure Notification Hub Luca DiFino dev.luke2375@live.it @luke2375 luke2375.wordpress.com MICROSOFT MOBILE CAMP ROMA, 12 Febbraio 2015
  • 2.
    Agenda • Overview • AzureNotification Hub • Let’s start • Hub • App • Push • Something more • More notifications • More channels • More apps • Q&A MOBILE CAMP ROMA, 12 Febbraio 2015
  • 3.
    • Push Notificationsoffer 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 MOBILE CAMP ROMA, 12 Febbraio 2015 3 Back-end PNS Device 1 2 3 4 Retrieve PNS Handle Store PNS Handle Send Notification Send to Device
  • 4.
    • Users management •Platform dependency • Scale • Refresh handles • Multicast • Routing • Monitor and telemetry MOBILE CAMP ROMA, 12 Febbraio 2015 4
  • 5.
    MOBILE CAMP ROMA, 12Febbraio 2015 5
  • 6.
  • 7.
    • Device tokenmanagement • 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 MOBILE CAMP ROMA, 12 Febbraio 2015
  • 8.
    MOBILE CAMP ROMA, 12Febbraio 2015 8
  • 9.
    Demo MOBILE CAMP ROMA, 12Febbraio 2015 9 +
  • 10.
    1. Create thenotification 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 MOBILE CAMP ROMA, 12 Febbraio 2015
  • 11.
    MOBILE CAMP ROMA, 12Febbraio 2015 11
  • 12.
    MOBILE CAMP ROMA, 12Febbraio 2015 12 1 2
  • 13.
    MOBILE CAMP ROMA, 12Febbraio 2015 13 1 2
  • 14.
    MOBILE CAMP ROMA, 12Febbraio 2015 14 SID Secret
  • 15.
    MOBILE CAMP ROMA, 12Febbraio 2015 15
  • 16.
    MOBILE CAMP ROMA, 12Febbraio 2015 16 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.Messaging.Managed • Set Toast capable in .appxmanifest • Create and register Notification Channel in app.xaml.cs
  • 17.
    • Add Nugetpackage WindowsAzure.ServiceBus • Create the hub • Send native notifications MOBILE CAMP ROMA, 12 Febbraio 2015 17 private NotificationHubClient hub; hub = NotificationHubClient.CreateClientFromConnectionString(endpoint, hubname); await hub.SendWindowsNativeNotificationAsync(XMLpayload); //WinRT await hub.SendMpnsNativeNotificationAsync(XMLpayolad); //Silverlight await hub.SendAppleNativeNotificationAsync(JSONpayload); //iOS await hub.SendGcmNativeNotificationAsync(JSONpayload); //Android
  • 18.
    MOBILE CAMP ROMA, 12Febbraio 2015 18 ToastText01 ToastImageAndText01
  • 19.
    MOBILE CAMP ROMA, 12Febbraio 2015 19 TileSquareImage/TileSquare150x150Image TileSquarePeekImageAndText02
  • 20.
    • What ifwe 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 MOBILE CAMP ROMA, 12 Febbraio 2015 20 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");
  • 21.
    • When inStandard tier, Notification Hubs supports a feature that enables you to schedule notifications up to 7 days in the future • To cancel a scheduled notification There are no limits on the number of scheduled notifications you can send MOBILE CAMP ROMA, 12 Febbraio 2015 21 Notification notification = new AppleNotification("{"aps":{"alert":"Happy birthday!"}}"); var scheduled = await hub.ScheduleNotificationAsync(notification, new DateTime(2014, 7, 19, 0, 0, 0)); await hub.CancelNotificationAsync(scheduled.ScheduledNotificationId);
  • 22.
    MOBILE CAMP ROMA, 12Febbraio 2015 22
  • 23.
    MOBILE CAMP ROMA, 12Febbraio 2015 23 var registration = await hub.RegisterNativeAsync(channel.Uri, tagsToSubscribeTo); await hub.UnregisterAsync(registration); await hub.UnregisterNativeAsync(); await hub.UnregisterAllAsync(channel.Uri);
  • 24.
    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 MOBILE CAMP ROMA, 12 Febbraio 2015 24
  • 25.
    MOBILE CAMP ROMA, 12Febbraio 2015 25
  • 26.
    Q&A MOBILE CAMP ROMA, 12Febbraio 2015 26 Feedback form

Editor's Notes

  • #8 Device token management store and manage channel URIs and device tokens used by Platform Notification Services securely handle the PNS feedback, device token expiry Scale broadcast to millions of devices with low latency Backend .NET, Node.JS, REST API, PHP, Java Personalization Each device can have one or more templates, to achieve per-device localization and personalization without affecting back-end code.