iphone - How to update notification badge number in iOS's home screen when received push message? -


i want ios device can auto update budges number in home screen (app not run). currently, i'm using push notification , it's can receive push notifications ok. budges number don't auto update (it's can update after clicked view detail push notice). questions how reload budges number when received push message app not run (background app) - line chat app? function show budges number in appdelegate bellow:

- (void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo {     int total_budges = [[userinfo objectforkey:@"badge_count"] intvalue]; [uiapplication sharedapplication].applicationiconbadgenumber = [uiapplication sharedapplication].applicationiconbadgenumber + total_budges; } 

thanks all!

- (void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo method never going called when application background state else in-active state need manage it's badge count back-end side.

that apns payload key or badge must have integer value. like

badge": 1 // value (1) must integer else badge not display. 

so when push notification arrive apple manage automatically display badge icon on application icon.

for clear count when application open used:

    [[uiapplication sharedapplication] setapplicationiconbadgenumber: 0];     [[uiapplication sharedapplication] cancelalllocalnotifications]; 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -