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

Commit

Permalink
Removing unnecessary wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Raghav Katyal committed Jul 6, 2015
1 parent 81fbdc2 commit 3138ed1
Showing 1 changed file with 55 additions and 56 deletions.
111 changes: 55 additions & 56 deletions src/windows8/PushPluginProxy.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,67 @@
cordova.define("com.adobe.phonegap.push.PushPlugin", function (require, exports, module) {
var myApp = {};
var pushNotifications = Windows.Networking.PushNotifications;
var myApp = {};
var pushNotifications = Windows.Networking.PushNotifications;

var createNotificationJSON = function (e) {
var result = {};
var notificationPayload;
var createNotificationJSON = function (e) {
var result = {};
var notificationPayload;

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

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

case pushNotifications.PushNotificationType.badge:
notificationPayload = e.badgeNotification.content.getXml();
break;
case pushNotifications.PushNotificationType.badge:
notificationPayload = e.badgeNotification.content.getXml();
break;

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

module.exports = {
init: function (onSuccess, onFail, args) {
module.exports = {
init: function (onSuccess, onFail, args) {

var onNotificationReceived = function (e) {
var result = createNotificationJSON(e);
onSuccess(result, { keepCallback: true });
}
var onNotificationReceived = function (e) {
var result = createNotificationJSON(e);
onSuccess(result, { keepCallback: true });
}

try {
pushNotifications.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync().done(
function (channel) {
var result = {};
result.registrationId = channel.uri;
myApp.channel = channel;
channel.addEventListener("pushnotificationreceived", onNotificationReceived);
myApp.notificationEvent = onNotificationReceived;
onSuccess(result, { keepCallback: true });
}, function (error) {
onFail(error);
});
} catch (ex) {
onFail(ex);
}
},
unregister: function (onSuccess, onFail, args) {
try {
myApp.channel.removeEventListener("pushnotificationreceived", myApp.notificationEvent);
myApp.channel.close();
onSuccess();
} catch(ex) {
onFail(ex);
}
try {
pushNotifications.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync().done(
function (channel) {
var result = {};
result.registrationId = channel.uri;
myApp.channel = channel;
channel.addEventListener("pushnotificationreceived", onNotificationReceived);
myApp.notificationEvent = onNotificationReceived;
onSuccess(result, { keepCallback: true });
}, function (error) {
onFail(error);
});
} catch (ex) {
onFail(ex);
}
},
unregister: function (onSuccess, onFail, args) {
try {
myApp.channel.removeEventListener("pushnotificationreceived", myApp.notificationEvent);
myApp.channel.close();
onSuccess();
} catch(ex) {
onFail(ex);
}
};
}
};
require("cordova/exec/proxy").add("PushNotification", module.exports);

});

0 comments on commit 3138ed1

Please sign in to comment.