Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows News app uses Notification Hubs Platform Notification Service App back-end Client app.

Similar presentations


Presentation on theme: "Windows News app uses Notification Hubs Platform Notification Service App back-end Client app."— Presentation transcript:

1

2

3

4

5 Windows News app uses Notification Hubs

6

7 Platform Notification Service App back-end Client app

8

9 APNsWNS Notification Hub App back-end iOS app Windows Store app

10

11

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

18

19

20 Notification Hub App back-end Tag:”Beatles”Tag:”Wailers” Tag:”Beatles”

21

22

23

24 Notification Hub App back-end

25

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

27

28

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

31

32

33

34

35

36

37

38

39


Download ppt "Windows News app uses Notification Hubs Platform Notification Service App back-end Client app."

Similar presentations


Ads by Google