更新徽章图标 [英] Update badge icon
问题描述
每当应用(在后台)收到推送通知时,我都会尝试更新徽章图标.
i try to update badge icon, every time when when the app (in background)receive a push notification.
我在didReceiveRemoteNotification"和didFinishLaunchingWithOptions"中使用了它
i used that in "didReceiveRemoteNotification" and "didFinishLaunchingWithOptions"
[UIApplication sharedApplication].applicationIconBadgeNumber++;
如果应用在前台并且收到的推送通知很少,当应用在后台返回时,图标的标志会根据收到的推送通知的数量更新.
If the app is in foreground and receive few push notifications, when the app come back in backgorund the icon's badge is updated with the number of push notifications received.
但是如果应用程序在后台,即使应用程序收到很多通知,图标的标志也总是 1,就像在有效载荷中一样.
But if the app is in background the icon's badge is allways 1 like in payload even the app receive many notifications.
你有什么想法吗?提前致谢
Do you have some ideas? Thanks in advance
推荐答案
发送到您设备的推送通知应具有 badge
数值,该数值将在收到推送时自动设置.
The push notifications that are sent to your device should have the badge
numeric value which will be et automatically when push is received.
服务器应该以某种方式处理您未读通知的数量,并在此字段中向您发送正确的显示数量.
The server should somehow handle the number of your unread notifications and it sends you the correct display number in this field.
这篇关于更新徽章图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!