Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Adding behavior for different notification types
Browse files Browse the repository at this point in the history
  • Loading branch information
Raghav Katyal committed Jul 8, 2015
1 parent 50d28cd commit beba29a
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions src/windows8/PushPluginProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,44 @@ var createNotificationJSON = function (e) {

switch (e.notificationType) {
case pushNotifications.PushNotificationType.toast:
notificationPayload = e.toastNotification.content.getXml();
break;
notificationPayload = e.toastNotification.content;
break;

case pushNotifications.PushNotificationType.tile:
notificationPayload = e.tileNotification.content.getXml();
break;
notificationPayload = e.tileNotification.content;
break;

case pushNotifications.PushNotificationType.badge:
notificationPayload = e.badgeNotification.content.getXml();
break;
notificationPayload = e.badgeNotification.content;
result.message = '';
result.count = notificationPayload.getElementsByTagName("badge")[0].getAttribute("value");
break;

case pushNotifications.PushNotificationType.raw:
notificationPayload = e.rawNotification.content;
break;
result.message = e.rawNotification.content;
break;
}
result.message = "";
result.xmlContent = notificationPayload;
result.objectReference = e;

if (e.notificationType === pushNotifications.PushNotificationType.toast || e.notificationType === pushNotifications.PushNotificationType.tile) {
var texts = notificationPayload.getElementsByTagName("text");
if (texts.length > 1) {
result.title = texts[0].innerText;
result.message = texts[1].innerText;
}
else {
result.message = texts[0].innerText;
}
var images = notificationPayload.getElementsByTagName("image");
if (images.length > 0) {
result.image = images[0].getAttribute("src");
}
var soundFile = notificationPayload.getElementsByTagName("audio");
if (soundFile.length > 0) {
result.sound = soundFile[0].getAttribute("src");
}
}
result.additionalData = {};
result.additionalData.objectReference = e;
return result;
}

Expand Down

0 comments on commit beba29a

Please sign in to comment.