IBM Worklight 6.1 - Tile badge from push notification never cleared on Windows Phone 8

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 12:53:55

问题


I'm using Worklight 6.1 and sending push notifications to Windows Phone 8. It is working swell, except for the tile badge. It is not being cleared when I use the tile to launch the app. The notification that I'm sending is:

{"APNS":{ … },"GCM":{ … },"SMS":{ … },"MPNS":{"raw":{"payload":{}},"toast":{"text1":"Luggage Tracker","text2":"You have 3 available messages"},"tile":{"count":3}}}

The toast message pops up, and the tile gets the badge, but the badge doesn't clear when I launch the app, and the only way I can find to clear it is to have the server push another notification with: tile {count:0}

Is there any way for the app to clear the tile badge?


回答1:


Update: the WL.Badge API is iOS-only. I have submitted an RFE to either enhance it or create specialized API for clearing the tile in Windows Phone 8 as well.

So the solution at this time, as I see it, is to create a Cordova plug-in to update the count... I found this plug-in. Perhaps you take from it when you need: https://github.com/sgrebnov/incubator-cordova-wp8/blob/master/plugins/www/plugins/LiveTiles/liveTilesExample.html


Use the WL.Badge.setNumber() API method.
Setting 0 should clear the badge from the tile.

WL.Badge.setNumber(0);

You can probably use this in the same logic that handles the received push (the one that shows the Toast pop up notification).

Worklight does not provide any mechanism to handle the badges other than methods to set or remove so you need to write one of your own.



来源:https://stackoverflow.com/questions/21197963/ibm-worklight-6-1-tile-badge-from-push-notification-never-cleared-on-windows-p

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