objective c - Application icon badge number not increasing : Xcode -
i facing problem push notification application badge number value updation.
i doing like:
-(void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo { uiapplicationstate state = [application applicationstate]; if (state == uiapplicationstateactive) { // stuff when app active }else{ // stuff when app in background [uiapplication sharedapplication].applicationiconbadgenumber = [uiapplication sharedapplication].applicationiconbadgenumber+1; /* increment icon badge number */ } }
but, icon showing badge number '1' always, , not incrementing when more notifications there/ 1 notification came after another.
any advice appreciable...
the badge number set operating system when receive json notification payload resembles following:
{ "aps" : { "alert" : "new notification!", "badge" : 2 } }
as see, it's server responsible setting correct number in badge
key. server needs track or compute number of pending notifications each user , generate badge
number before sending notification apple.
the client responsibility clear notification badge, or decrement it, when user sees notification. code is
application.applicationiconbadgenumber = application.applicationiconbadgenumber - 1; // decrement counter
or
application.applicationiconbadgenumber = 0; // reset counter assuming user able see notifications @ once.
Comments
Post a Comment