ios - Update badge icon when app is in background/suspended mode -


i want update application badge icon when notification received. works fine when app running (active mode),but having trouble when trying set when app in suspended/background mode. want achieve same without using 'badge' field in apns dictionary.

here doing,

-(void) incrementonebadge{ nsinteger numberofbadges = [uiapplication sharedapplication].applicationiconbadgenumber; numberofbadges +=1;    [[uiapplication sharedapplication] setapplicationiconbadgenumber:numberofbadges];  }  -(void) decrementonebadge{ nsinteger numberofbadges = [uiapplication sharedapplication].applicationiconbadgenumber; numberofbadges -=1;    [[uiapplication sharedapplication] setapplicationiconbadgenumber:numberofbadges]; }  -(void) application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo fetchcompletionhandler:(void (^)(uibackgroundfetchresult))completionhandler {   uiapplicationstate state = [application applicationstate];   if (state == uiapplicationstateactive) {    }    else {     // push notification received in background     [self incrementonebadge];    }    [self handlepushnotificationsforstate:application withdictionary:userinfo]; } 


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -