SlideShare une entreprise Scribd logo
1  sur  41
Me
adam grocholski

adgroc@microsoft.com
@codel8r
thinkfirstcodelater.com
Client app

Platform
Notification
Service

App back-end
Android app

Windows Store
app

App back-end

GCM

Notification Hub

WNS
//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);
//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);
No need to store and maintain gcmId.
Device registrations expire.
App back-end
Tag:”Beatles”

Notification Hub

Tag:”Wailers”

Tag:”Beatles”
//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");
//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);
Notification Hub
App back-end
<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)”
}
}
<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)”
}
}
//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");
//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);
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!
Contact Me
adam grocholski

adgroc@microsoft.com
@codel8r
thinkfirstcodelater.com
Using Notification Hubs for cross-platform push notifications

Contenu connexe

Tendances

Будь первым
Будь первымБудь первым
Будь первымFDConf
 
bank management system
bank management systembank management system
bank management systemAisha Aisha
 
All you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, GeneratorsAll you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, GeneratorsBrainhub
 
Jeroen Vloothuis Bend Kss To Your Will
Jeroen Vloothuis   Bend Kss To Your WillJeroen Vloothuis   Bend Kss To Your Will
Jeroen Vloothuis Bend Kss To Your WillVincenzo Barone
 
The Ring programming language version 1.5.2 book - Part 40 of 181
The Ring programming language version 1.5.2 book - Part 40 of 181The Ring programming language version 1.5.2 book - Part 40 of 181
The Ring programming language version 1.5.2 book - Part 40 of 181Mahmoud Samir Fayed
 
Curlin' for Docs
Curlin' for DocsCurlin' for Docs
Curlin' for DocsSmartLogic
 

Tendances (6)

Будь первым
Будь первымБудь первым
Будь первым
 
bank management system
bank management systembank management system
bank management system
 
All you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, GeneratorsAll you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, Generators
 
Jeroen Vloothuis Bend Kss To Your Will
Jeroen Vloothuis   Bend Kss To Your WillJeroen Vloothuis   Bend Kss To Your Will
Jeroen Vloothuis Bend Kss To Your Will
 
The Ring programming language version 1.5.2 book - Part 40 of 181
The Ring programming language version 1.5.2 book - Part 40 of 181The Ring programming language version 1.5.2 book - Part 40 of 181
The Ring programming language version 1.5.2 book - Part 40 of 181
 
Curlin' for Docs
Curlin' for DocsCurlin' for Docs
Curlin' for Docs
 

Similaire à Using Notification Hubs for cross-platform push notifications

Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...KAI CHU CHUNG
 
Android Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmAndroid Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmJohan Nilsson
 
MAF push notifications
MAF push notificationsMAF push notifications
MAF push notificationsLuc Bors
 
Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)남균 김
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it meansRobert Nyman
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwrdeimos
 
Scaling push notifications to millions of devices using notification hubs
Scaling push notifications to millions of devices using notification hubsScaling push notifications to millions of devices using notification hubs
Scaling push notifications to millions of devices using notification hubscloudbeatsch
 
St. Louis Day of .NET 2013 - Delivering Push Notifications to Millions of Mob...
St. Louis Day of .NET 2013 - Delivering Push Notifications to Millions of Mob...St. Louis Day of .NET 2013 - Delivering Push Notifications to Millions of Mob...
St. Louis Day of .NET 2013 - Delivering Push Notifications to Millions of Mob...Adam Grocholski
 
Developing for Chromecast on Android
Developing for Chromecast on AndroidDeveloping for Chromecast on Android
Developing for Chromecast on AndroidKurt Mbanje
 
Android chat in the cloud
Android chat in the cloudAndroid chat in the cloud
Android chat in the cloudfirenze-gtug
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile servicesAymeric Weinbach
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web ToolkitsYiguang Hu
 
A Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to BluemixA Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to Bluemixibmwebspheresoftware
 
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformRobert Nyman
 
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Dan Wahlin
 
Push Notification in IBM MobileFirst Xamarin SDK
Push Notification in IBM MobileFirst Xamarin SDKPush Notification in IBM MobileFirst Xamarin SDK
Push Notification in IBM MobileFirst Xamarin SDKAjay Chebbi
 
Magento 2 Seminar - Anton Kril - Magento 2 Summary
Magento 2 Seminar - Anton Kril - Magento 2 SummaryMagento 2 Seminar - Anton Kril - Magento 2 Summary
Magento 2 Seminar - Anton Kril - Magento 2 SummaryYireo
 

Similaire à Using Notification Hubs for cross-platform push notifications (20)

GCM aperitivo Android
GCM aperitivo AndroidGCM aperitivo Android
GCM aperitivo Android
 
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...Dev fest 2020 taiwan   how to debug microservices on kubernetes as a pros (ht...
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
 
Android Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmAndroid Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG Stockholm
 
MAF push notifications
MAF push notificationsMAF push notifications
MAF push notifications
 
Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)Build resource server &amp; client for OCF Cloud (2018.8.30)
Build resource server &amp; client for OCF Cloud (2018.8.30)
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
 
Joe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand DwrJoe Walker Interactivewebsites Cometand Dwr
Joe Walker Interactivewebsites Cometand Dwr
 
Scaling push notifications to millions of devices using notification hubs
Scaling push notifications to millions of devices using notification hubsScaling push notifications to millions of devices using notification hubs
Scaling push notifications to millions of devices using notification hubs
 
St. Louis Day of .NET 2013 - Delivering Push Notifications to Millions of Mob...
St. Louis Day of .NET 2013 - Delivering Push Notifications to Millions of Mob...St. Louis Day of .NET 2013 - Delivering Push Notifications to Millions of Mob...
St. Louis Day of .NET 2013 - Delivering Push Notifications to Millions of Mob...
 
Developing for Chromecast on Android
Developing for Chromecast on AndroidDeveloping for Chromecast on Android
Developing for Chromecast on Android
 
Android chat in the cloud
Android chat in the cloudAndroid chat in the cloud
Android chat in the cloud
 
Cnam azure 2014 mobile services
Cnam azure 2014   mobile servicesCnam azure 2014   mobile services
Cnam azure 2014 mobile services
 
Google Web Toolkits
Google Web ToolkitsGoogle Web Toolkits
Google Web Toolkits
 
Android Froyo
Android FroyoAndroid Froyo
Android Froyo
 
A Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to BluemixA Node.js Developer's Guide to Bluemix
A Node.js Developer's Guide to Bluemix
 
JavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the PlatformJavaScript APIs - The Web is the Platform
JavaScript APIs - The Web is the Platform
 
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
Building the an End-to-End ASP.NET MVC 4, Entity Framework, HTML5, jQuery app...
 
Push Notification in IBM MobileFirst Xamarin SDK
Push Notification in IBM MobileFirst Xamarin SDKPush Notification in IBM MobileFirst Xamarin SDK
Push Notification in IBM MobileFirst Xamarin SDK
 
Magento 2 Seminar - Anton Kril - Magento 2 Summary
Magento 2 Seminar - Anton Kril - Magento 2 SummaryMagento 2 Seminar - Anton Kril - Magento 2 Summary
Magento 2 Seminar - Anton Kril - Magento 2 Summary
 
Serverless
ServerlessServerless
Serverless
 

Dernier

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 

Dernier (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 

Using Notification Hubs for cross-platform push notifications

  • 1.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 14.
  • 15. Android app Windows Store app App back-end GCM Notification Hub WNS
  • 16.
  • 17.
  • 18. //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);
  • 19. //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);
  • 20. No need to store and maintain gcmId. Device registrations expire.
  • 21.
  • 23. //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");
  • 24. //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);
  • 25.
  • 26.
  • 28.
  • 29.
  • 30. <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)” } }
  • 31. <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)” } }
  • 32. //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");
  • 33. //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);
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39. 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!