Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix(windows8): Adds missing notification received event handler

  • Loading branch information...
commit 9839dd4f20f71a4bc8a7c0b98b3ec338cab3d25f 1 parent 42aad07
@sgrebnov authored
Showing with 23 additions and 0 deletions.
  1. +23 −0 src/windows8/NotificationHubProxy.js
View
23 src/windows8/NotificationHubProxy.js
@@ -24,11 +24,34 @@ module.exports = {
var notificationHubPath = args[0];
var connectionString = args[1];
var pushNotificationCallback = window[args[2]];
+ var pushNotificationHandler = function (e) {
+ var notification = null;
+ try {
+ var notificationType = Windows.Networking.PushNotifications.PushNotificationType;
+ switch (e.notificationType) {
+ case notificationType.toast:
+ notification = e.toastNotification.content;
+ notification.notificationTypeName = "Toast";
+ break;
+ case notificationType.tile:
+ notification = e.tileNotification.content;
+ notification.notificationTypeName = "Tile";
+ break;
+ case notificationType.badge:
+ notification = e.badgeNotification.content;
+ notification.notificationTypeName = "Badge";
+ break;
+ }
+ pushNotificationCallback(notification);
+ } catch (ex) {}
+ e.cancel = true;
+ }
var notificationChannel = null;
Windows.Networking.PushNotifications.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync().then(function (channel) {
notificationChannel = channel;
+ notificationChannel.addEventListener('pushnotificationreceived', pushNotificationHandler);
return (new NotificationHubRuntimeProxy.HubApi()).registerNativeAsync(notificationHubPath, connectionString, channel.uri);
}).done(function (result) {
var regInfo = {};
Please sign in to comment.
Something went wrong with that request. Please try again.