27
Delivering push notifications to millions of mobile devices

Mobile March Windows Azure Notification Hubs

Embed Size (px)

DESCRIPTION

Push notifications are critical to craft engaging app experience and increase usage and user interest. Windows Azure Notification Hubs support multi-platform push with Windows, iOS, and Android, publish/subscribe routing to particular groups of users or devices, and low latency broadcast to millions of devices. Join us to learn how to use Notification Hubs to target millions of devices at once and single targeted users with just a few lines of code. Easily provide push notification support for Windows, Windows Phone, iOS, and Android, easily send broadcast messages to all users or targeted messages to specific users, start free, scale up and down as needed.

Citation preview

Page 1: Mobile March Windows Azure Notification Hubs

Delivering push notifications to millions of mobile devices

Page 2: Mobile March Windows Azure Notification Hubs

[email protected]@codel8r

thinkfirstcodelater.com

Me

adam grocholski

Page 3: Mobile March Windows Azure Notification Hubs

Notification Hubs…

Page 4: Mobile March Windows Azure Notification Hubs

…any easy way to send personalized notifications both to single users and very large groups…

Page 5: Mobile March Windows Azure Notification Hubs

…regardless of platform.

Page 6: Mobile March Windows Azure Notification Hubs

Agenda

Push notificationsNotification hubsTagsTemplates

Page 7: Mobile March Windows Azure Notification Hubs

Why Push?

Push is essential to the user experience of many apps.Increase user engagement.• Update tiles/widgets with current financial/weather information.• Display badges with the number of current sales leads in a CRM app.

Real world apps have complex needs.Multi-platform push.Localization.User preferences.Different client app versions.Scale.

Page 8: Mobile March Windows Azure Notification Hubs

Push notifications

Push notifications require a platform specific service.Each platform (Windows Store, iOS, Android, …) has a different push notification service.Different capabilities and protocols.

An e2e solution requires lots of back-end code.Store and keep up to date the device information.Implement platform-specific protocols.

Page 9: Mobile March Windows Azure Notification Hubs

Push notification lifecycle

Registration at app launch1. Client app contacts Platform Notification Service,

to retrieve current channel (e.g., ChannelURIs, device tokens, registrationIds).

2. App updates handle in back-end.

Sending notification3. App back-end send notification to PNS.4. PNS pushes the notification to the app

on the device.

Maintenance5. Delete expired handles when PNS rejects them.

PlatformNotification

Service

App back-end

Client app

Page 10: Mobile March Windows Azure Notification Hubs

Challenges of push notifications

Platform dependencyDifferent communication protocols to PNS’ (e.g., HTTP vs. TCP, xml payload vs. JSON payload).Different presentation formats and capabilities (tiles vs. toasts vs. badges).

RoutingPNS’ provide a way to send a message to a device/channel.Usually notifications are targeted at users or interest groups(e.g., employees assigned to a customer account).App back-end has to maintain a registry associating device handles to interest groups/users.

ScaleApp back-end has to store current handles for each device high storage and VM costs.Broadcast to millions of devices with low latency requires parallelization (DB ad VM).

Page 11: Mobile March Windows Azure Notification Hubs

Why Notification Hubs?

One-time set upCreate a Notification Hub in Service Bus.

RegisterThe client app retrieves its current handle from the PNS.Client app creates (or updates) a registration on the Notification Hub with the current handle.

Send NotificationThe app back-end sends a message to the Notification Hub.Notification Hub pushes it to the PNS’.

GCM WNS

Notification Hub

App back-end

Android app Windows Storeapp

Page 12: Mobile March Windows Azure Notification Hubs

Advantages of using Notification HubsNo platform-specific protocols.App back-end just communicates with the Notification Hub.

Avoid storing device information in the app back-end.Notification Hub maintains the registry of devices and the associations to users/interest groups.

BroadcastPush notifications to millions of devices (across platforms) with a single call.

Page 13: Mobile March Windows Azure Notification Hubs

Sending notifications to specific devicesTags as interest groups.1. Client app can register with a set of tags.2. Tags are simple strings (no pre-provisioning is required).3. App back-end can target all clients with the same tag.

You can use tags also for:Multiple type of interest groups, e.g.,:• Follow bands: tag “followband:Beatles”.• Follow users: tag “followuser:Alice”.

Tag devices with a user ID.

Notification Hub

App back-end

Tag:”Beatles”Tag:”Wailers”

Tag:”Beatles”

Page 14: Mobile March Windows Azure Notification Hubs

Using templates for multi-platform pushRegistration.Client apps can register with a platform specific template, e.g.,• Alice’s Surface registers with

Windows Store ToastText01 template.• Bob’s iPhone with the Apple JSON template:

{ aps: {alert: “$(message)”}}.

Send notification.App back-end sends a platform independent message: {message: “Hello!”}.

Version independence.Templates can be used to abstract different client app versions.

Service Bus Notification HubApp back-

end

<toast><visual><binding

template=\"ToastText01\"><text

id=\"1\">$(message)</text></binding>

</visual></toast>

{aps: {

alert: “$(message)”

}}

{ message: “Hello!” }

Hello!

Hello

!

Page 15: Mobile March Windows Azure Notification Hubs

Enough talk…show me the code!

Page 16: Mobile March 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!

Page 17: Mobile March Windows Azure Notification Hubs

Can't make it to San Francisco to attend Build this year? No worries, we've got you covered. Join us at the local Microsoft office to watch the live stream of this year's keynote. We can't say much at this point, other than that the content will be amazing.

We know it' during lunch, and we know how developers can get when they're not fed. Have no fears, food and beverage will be provided. We'll also have a few giveaways including:

• Nokia Lumia 1020's• Dell Venue 8 Pro Tablets

Register Now: http://aka.ms/build2014mn

Page 18: Mobile March Windows Azure Notification Hubs

Register Now: http://aka.ms/gwabcmn

When?Saturday, March 29, 2014, 9:00 AM – 4:30 PM

Where?SoMakers

Why?Get bootstrapped into developing application leveraging all Windows Azure has to offer

Page 19: Mobile March Windows Azure Notification Hubs

[email protected]@codel8r

thinkfirstcodelater.com

Contact Me

adam grocholski

Page 20: Mobile March Windows Azure Notification Hubs

© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Page 21: Mobile March Windows Azure Notification Hubs

//instantiate a new NotificationHub instance

NotificationHub hub = new NotificationHub("<hub name>", "<connection string>", context);

Register an Android app

//get the gcm id

GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);

String gcmid = gcm.register(SENDER_ID);

//register with the NotificationHub

NativeRegistration r = hub.register(gcmid);

Page 22: Mobile March Windows Azure Notification Hubs

Broadcast Android notifications (C#)

//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);

Page 23: Mobile March Windows Azure Notification Hubs

Register an iOS app

(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *) deviceToken {

SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:

@"<connection string>" notificationHubPath:@“<hub>"];

[hub registerNativeWithDeviceToken:deviceToken tags:nil completion:^(NSError* error) {

if (error != nil) {

NSLog(@"Error registering for notifications: %@", error);

}

}];

}

Page 24: Mobile March Windows Azure Notification Hubs

Broadcast iOS notification (C#)

var hubClient = NotificationHubClient.CreateClientFromConnectionString("<connection string>", “<hub name>");

var toastForIos = @“<notification payload>";

hubClient.SendAppleNativeNotificationAsync(toastForIos);

Page 25: Mobile March Windows Azure Notification Hubs

Delivery guarantee and telemetryNotification Hubs do not provide delivery guarantee.All platform notification systems are “best effort”, e.g., device could be disconnected, could never reconnect, etc.Guideline: important communications have to be delivered in-app.

Telemetry.Notification Hubs provide powerful telemetry to track each and every outcome of the notifications for each platform (e.g., successful notifications, throttled notifications, expired channels/tokens).Accessible through Windows Azure portal and programmatically.

Page 26: Mobile March Windows Azure Notification Hubs

Scale

Notification Hubs run on a fully parallelized architecture.All our VMs are ready for your broadcast!A single Notification Hub scales up to millions of devices, with no special coding required.

Number of devices and latency.Notification Hubs support millions of devices out of the box.The expected latency of a broadcast to all registered devices is a couple of minutes, even for millions of devices.

Page 27: Mobile March Windows Azure Notification Hubs

Platform support

Platform support.We support push notifications through WNS, APNs, GCM, and MPNS.Device SDKs for Windows Store Apps, Windows Phone 8, iOS (Objective-C), Android.Server SDKs for .NET, Node, Mobile Services.All functions available from REST.