I have configured push notification in Android and IOS, and it's works perfectly. but when I configured Non-authenticated push notification for windows phone 8 in worklight, it's not working.I follow the below MobileFirst document to run push notification for windows Phone 8:
Also i want to know, for subscription based push notification, which notification is recommended for windows phone 8 i.e. Non-authenticated push or Authenticated push?
Below is my code:
adapter.js
function submitNotification(userId, notificationText){
var userSubscription = WL.Server.getUserNotificationSubscription('PushAdapter.PushEventSource', userId);
if (userSubscription==null){
return { result: "No subscription found for user :: " + userId };
}
var notification={};
notification.MPNS={};
var badgeDigit = 1;
var notification = WL.Server.createDefaultNotification(notificationText, badgeDigit, {custom:"data"});
notification.MPNS.toast={};
notification.MPNS.toast.text1 = "Toast title";
notification.MPNS.toast.text2 = "Toast content";
WL.Logger.debug("submitNotification >> userId :: " + userId + ", text :: " + notificationText);
WL.Server.notifyAllDevices(userSubscription, notification);
return {
result: "Notification sent to user :: " + userId
};
}
application-descriptor.xml
<windowsPhone8 version="1.0">
<uuid>5747-54938-fjhg-f459-844h-fhkj</uuid>
</windowsPhone8>
Please help me on windows phone 8 push notification.
++++++++++++++++++++++++++++++Update Question+++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ After adding push sender id in "application-descriptor.xml". push notification is working on windows phone8. but facing problem to receive broadcast notification on windows phone8.
broadcastAdapter.js
function sendBroadcastNotification(applicationId, notificationText) {
var notificationOptions = {};
notificationOptions.message = {};
notificationOptions.message.alert = notificationText;
WL.Server.sendMessage(applicationId, notificationOptions);
return {
result : "Notification sent to all users."
};
}
client side code in main.js:
if(WL.Client.Push){
WL.Client.Push.onMessage = function (props, payload) {
navigationFromNotification = true;
WL.SimpleDialog.show("Tag Notifications", "Provider notification data: " + JSON.stringify(props), [ {
text : 'Close',
handler : function() {
WL.SimpleDialog.show("Brodcast Notifications", "Application notification data: " + JSON.stringify(payload), [ {
text : 'Close',
handler : function() {
window.location.href="#/home/2";
}
}]);
}
}]);
};
}
Am I need to add anything to receive broadcast Notification on windows phone8 ?