iPhone: Increment badge counter automatically [duplicate]

ぐ巨炮叔叔 提交于 2019-12-06 07:43:24

问题


Possible Duplicate:
Push-Notification Badge auto increment.

I have implemented Push Notification for my iPhone application. Whenever I get the message, I want to increment badge value by one so I need not to pass it in Push Notification payload. Is it possible?

From here I learnt that I have to manage that from server side, so that's the only way? I had to store the previous value in Database and get the last value whenever I send next message? Isn't Apple support this automatically like incrementing application.applicationIconBadgeNumber whenever Push Notification received.

The problem with managing Badge number from server side is if user has already seen the previous Push Notification message, you would send wrong badge number!


回答1:


It's not really a problem. The client just needs to let the server know what messages it has seen. Everyone else is doing it, so just learn how to do it and do it.

EDIT: You can set the badge counter using:

[UIApplication sharedApplication].applicationIconBadgeNumber = badgeCount;

Every time you do, you should send badgeCount to the server, so that the server knows the current count.



来源:https://stackoverflow.com/questions/6212116/iphone-increment-badge-counter-automatically

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