Toast for Push Notification on Windows Phone 8 using Worklight 6.1

半城伤御伤魂 提交于 2020-01-07 04:10:12

问题


I'm using Worklight 6.1 and sending push notifications to Windows Phone 8 using unauthenticated procedure.

I am creating the notification by using the following procedure. This procedure updates the tile and badge but doesn't generates a toast notification:
WL.Server.createDefaultNotification(notificationText, badgeDigit, {custom:"data"});

  1. What is the correct procedure for adding a "toast" to a received push notification on Windows Phone 8?
  2. Also, is there any way to clear the notification on the tile once the application is launched by clicking it?

回答1:


  1. The WL.Server.createDefaultNotiication API method returns only the raw and tile notification types for Windows Phone 8. To add a toast notification, see the example below.

    var notification = WL.Server.createDefaultNotification("You have " + numCoupons + " coupons.", numCoupons, {foo: "bar"});
    
    notification.MPNS.toast = {};
    notification.MPNS.toast.text1 = "Toast title”;
    notification.MPNS.toast.text2 = "Toast content”;
    
  2. To clear the number from the application icon, or tile, the WL.Badge method should be used. However, in Worklight 6.1 this method is applicable only for the iOS environment (see also this question for a possible alternative).

    Starting Worklight 6.2, WL.Badge is applicable for Windows Phone 8 as well.



来源:https://stackoverflow.com/questions/26583133/toast-for-push-notification-on-windows-phone-8-using-worklight-6-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!