Toast for Push Notification on Windows Phone 8 usi

2019-09-03 07:45发布

问题:

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.