Download presentation
Presentation is loading. Please wait.
Published byRandall Stevenson Modified over 9 years ago
5
Windows News app uses Notification Hubs
7
Platform Notification Service App back-end Client app
9
APNsWNS Notification Hub App back-end iOS app Windows Store app
12
var hub = new NotificationHub(“ ", " "); var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); await hub.RegisterNativeAsync(channel.Uri);
13
var hubClient = NotificationHubClient.CreateClientFromConnectionString(" ", “ "); var toast = @“ "; hubClient.SendWindowsNativeNotificationAsync(toast);
14
(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *) deviceToken { … SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString: @" " notificationHubPath:@"mynh"]; [hub registerNativeWithDeviceToken:deviceToken tags:nil completion:^(NSError* error) { if (error != nil) { NSLog(@"Error registering for notifications: %@", error); } }]; }
15
In your main activity: Notification Hub hub = new NotificationHub(" ", " ", context); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String regid = gcm.register(SENDER_ID); NativeRegistration r = hub.register(regid);
16
var hubClient = NotificationHubClient.CreateClientFromConnectionString(" ", “ "); var toastForIos = @“ "; hubClient.SendAppleNativeNotificationAsync(toastForIos); var toastForAndroid = @“ "; hubClient.SendGcmNativeNotificationAsync(toastForAndroid);
17
var azure = require('azure'); var notificationHubService = azure.createNotificationHubService('hubname', 'connectionString'); notificationHubService.wns.sendToastText01(null, { text1: 'Hello from Node and Mobile Services!' }, function (error) { if (!error) { // message sent successfully } } );
20
Notification Hub App back-end Tag:”Beatles”Tag:”Wailers” Tag:”Beatles”
24
Notification Hub App back-end
26
// POST api/register public async void Post(bool instId, bool channelUri, bool userId) { // We assume a windows store app (if coding a multiplatform app, a ‘platform‘ parameter should be passed) … if (!authorizedToRegisterTag(userId)) { throw new Exception("User not authorized to register"); } var regsForInstId = await hubClient.GetRegistrationsByTag(instId, 100); bool updated = false; bool firstRegistration = true; foreach (var registrationDescription in regsForInstId) { if (firstRegistration) { var winReg = registrationDescription as WindowsRegistrationDescription; winReg.ChannelUri = new Uri(channelUri); winReg.Tags.Clear(); winReg.Tags.UnionWith(new string[] {instId, userId}); hubClient.UpdateRegistration(winReg); updated = true; firstRegistration = false; } else { // if templates are not used, delete all extra registrations with this installation id. hubClient.DeleteRegistration(registrationDescription); } // if not updated, a new registration has to be created for the device if (!updated) { hubClient.CreateWindowsNativeRegistration(channelUri, new string[] {instId, userId}); }
29
Service Bus Notification Hub App back-end $(message) { aps: { alert: “$(message)” } { message: “Hello!” } Hello!
30
Service Bus Notification Hub App back-end $(tempF) { aps: { alert: “$(tempC)” } { tempC: “23”, tempF: “73” } 73 23
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.