问题
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