Skip to content

Commit

Permalink
fix(windows8): Adds missing notification received event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrebnov committed Mar 3, 2014
1 parent 42aad07 commit 9839dd4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/windows8/NotificationHubProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down

0 comments on commit 9839dd4

Please sign in to comment.