際際滷

際際滷Share a Scribd company logo
Google DevFest MN - Windows Azure Notification Hubs
Me
adam grocholski

adgroc@microsoft.com
@codel8r
thinkfirstcodelater.com
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Client app

Platform
Notification
Service

App back-end
Google DevFest MN - Windows Azure Notification Hubs
Android app

Windows Store
app

App back-end

GCM

Notification Hub

WNS
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
//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.
Google DevFest MN - Windows Azure Notification Hubs
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);
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Notification Hub
App back-end
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
<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);
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
Google DevFest MN - Windows Azure Notification Hubs
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
Google DevFest MN - Windows Azure Notification Hubs

More Related Content

Google DevFest MN - Windows Azure Notification Hubs