通知徽章编号增量
如何增加徽章编号以及如何知道用户是否打开通知。因此可以决定是增加徽章编号还是从头开始。
alertNotification.Payload.Sound = "default";
alertNotification.Payload.Badge = 1;
How to increment the badge number and how to know whether the user opens the notifications.so v could whether to increnment the badge no or to start from the begining.
alertNotification.Payload.Sound = "default";
alertNotification.Payload.Badge = 1;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有 API 可以增加徽章编号。您需要将所有状态存储在服务器上,因为您拥有的唯一 API 就是发送完整的数字以与应用程序图标一起显示。根本没有其他办法。您已经存储了用户设备令牌,因此您可以轻松地将“badgeCount”属性添加到您用于持久性的任何系统中。
如果用户通过应用委托上的
application:didReceiveRemoteNotification:
推送通知打开应用,您将收到通知。您可以在那里做任何您想做的事情来通知您的服务器当前的事务状态。您可能还想在application:didBecomeActive:
等中执行此操作,以防用户手动而不是通过通知打开应用程序。There are no APIs to increment the badge number. You need to store all the state on the server, since the only API you have is to send the full number to display with the app icon. There's simply no other way. You already store the users device token, so you can probably easily add a "badgeCount" attribute to whatever system you use for persistence.
You'll get notified if the user opens the app via the push notifications with
application:didReceiveRemoteNotification:
on the app delegate. You can do whatever you want in there to inform your server about the current state of affairs. You might also want to do so inapplication:didBecomeActive:
etc, in case the user opens the app manually instead of via the notification.