Google DevFest MN - Windows Azure Notification Hubs

  • 541 views
Uploaded on

 

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
541
On Slideshare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
4
Comments
1
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Me adam grocholski adgroc@microsoft.com @codel8r thinkfirstcodelater.com
  • 2. Client app Platform Notification Service App back-end
  • 3. Android app Windows Store app App back-end GCM Notification Hub WNS
  • 4. //get the gcm id GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String gcmid = gcm.register(SENDER_ID); //instantiate a new NotificationHub instance NotificationHub hub = new NotificationHub("<hub name>", "<connection string>", context); //register with the NotificationHub NativeRegistration r = hub.register(gcmid);
  • 5. //instantiate a new instance of NotificationHubClient var hubClient = NotificationHubClient.CreateClientFromConnectionString("<connection string>", "<hub name>"); //create the json payload for the notification var payload = "{ "data" : {"msg":"Hello from Windows Azure!"}}"; //send notification via gcm hubClient.SendGcmNativeNotificationAsync(payload);
  • 6. No need to store and maintain gcmId. Device registrations expire.
  • 7. App back-end Tag:”Beatles” Notification Hub Tag:”Wailers” Tag:”Beatles”
  • 8. //get the gcm id GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String gcmid = gcm.register(SENDER_ID); //instantiate a new NotificationHub instance NotificationHub hub = new NotificationHub("<hub name>", "<connection string>", context); //register with the NotificationHub using tags NativeRegistration r = hub.register(gcmid, "Beatles");
  • 9. //instantiate a new instance of NotificationHubClient var hubClient = NotificationHubClient.CreateClientFromConnectionString("<connection string>", "<hub name>"); //create the json payload for the notification var payload = "{ "data" : {"msg":"Hello from Windows Azure!"}}"; //create a list of tags var tags = new List<string>(){ "Beatles" }; //send notification to devices registered with tags via gcm hubClient.SendGcmNativeNotificationAsync(payload, tags);
  • 10. Notification Hub App back-end
  • 11. <toast> <visual> <binding template="ToastText01"> <text id="1">$(message)</text> </binding> </visual> </toast> Hello! { message: “Hello!” } App back-end Service Bus Notification Hub Hello! { aps: { alert: “$(message)” } }
  • 12. <toast> <visual> <binding template="ToastText01"> <text id="1">$(tempF)</text> </binding> </visual> </toast> 73 {tempC: “23”, tempF: “73”} App back-end Service Bus Notification Hub 23 { aps: { alert: “$(tempC)” } }
  • 13. //get the gcm id GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String gcmid = gcm.register(SENDER_ID); //instantiate a new NotificationHub instance NotificationHub hub = new NotificationHub("<hub name>", "<connection string>", context); //create the template String template = "{ "data" : {"msg":"$(message)"}}"; //register with the NotificationHub using the template NativeRegistration r = hub.register(gcmid, "Template1", template, "Beatles");
  • 14. //instantiate a new instance of NotificationHubClient var hubClient = NotificationHubClient.CreateClientFromConnectionString("<connection string>", "<hub name>"); //create expressions to substitute in the template var expressions = var Dictionary<string, string>(); expressions.Add("message", "hello"); //send template notification to all devices hubClient.SendTemplateNotificationAsync(expressions);
  • 15. What Next? Try it out. For Free. Build what you want. Scale as you need. Full access with no strings attached. http://aka.ms/thecloud Hello startups! You have an ideas so brilliant it burns. BizSpark can help make it real. http://aka.ms/JoinBizSpark or CONTACT ME!
  • 16. Contact Me adam grocholski adgroc@microsoft.com @codel8r thinkfirstcodelater.com