Created
August 3, 2012 23:42
-
-
Save ferclaverino/3252745 to your computer and use it in GitHub Desktop.
a module to register to WNS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
"use strict"; | |
function request() { | |
var WNSRegistrationUrl = ApplicationConfiguration.getServiceRootSite() + "/MyService/Register"; | |
var notificationChannel = Windows.Networking.PushNotifications.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync(); | |
notificationChannel | |
.then(function (channel) { | |
// suscribo al evento de notificacion recibida p/limpiar el cache | |
channel.addEventListener("pushnotificationreceived", onPushNotificationReceived); | |
var URIdata = '{"URI":"' + channel.uri + '"}'; | |
return WinJS.xhr({ | |
type: "POST", | |
url: WNSRegistrationUrl, | |
headers: { "Content-Type": "application/json; charset=utf-8" }, | |
data: URIdata | |
}); | |
}).then(function (response) { | |
var status = response; | |
}); | |
} | |
function onPushNotificationReceived(eventArgs) { | |
var homeNewsQuery = new Queries.HomeNewsCachedQuery(); | |
homeNewsQuery.flushCache(); | |
} | |
// Export public methods | |
WinJS.Namespace.define("PushNotification", | |
{ | |
request: request | |
} | |
); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment