Pousser le count de badge de notification ne pas mettre à jour

Ceci est mon code pour la notification Apple Push, lorsque l'application est en cours d'exécution et la notification à venir j'augmente le nombre de badge et get le résultat souhaité lorsque je clique sur le button d'accueil, sur l'icône de l'application. mais quand je ne cours pas mon application et la notification vient, il n'a pas augmenté automatiquement le count de badge et rest à seulement 1. la valeur 1 vient du server. quelqu'un peut-il indiquer où je me trompe? Merci d'avance.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { userMessageCounter = @"0"; postType = 0; joinedStreamChecker = 0; OwnerValue = 0; pushValue = 1; badgeValue =0; // Override point for customization after application launch. // Add the navigation controller's view to the window and display. [self.window addSubview:navigationController.view]; [self.window makeKeyAndVisible]; [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)]; //[[UIApplication sharedApplication] registerForRemoteNotificationTypes: //(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)]; [UIApplication sharedApplication].applicationIconBadgeNumber = 0; // [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeNewsstandContentAvailability | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert)]; UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; if (types == UIRemoteNotificationTypeNone) { pushValue = 0; NSLog(@"notification off"); } return YES; } - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken1 { NSSsortingng *str = [NSSsortingng ssortingngWithFormat:@"%@",deviceToken1]; NSLog(@"%@",str); self.deviceToken = [NSSsortingng ssortingngWithFormat:@"%@",str]; NSLog(@"dev --- %@",self.deviceToken); self.deviceToken = [self.deviceToken ssortingngByReplacingOccurrencesOfSsortingng:@"<" withSsortingng:@""]; self.deviceToken = [self.deviceToken ssortingngByReplacingOccurrencesOfSsortingng:@" " withSsortingng:@""]; self.deviceToken = [self.deviceToken ssortingngByReplacingOccurrencesOfSsortingng:@">" withSsortingng:@""]; NSLog(@"dev --- %@",self.deviceToken); } - (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err { NSSsortingng *str = [NSSsortingng ssortingngWithFormat: @"Error: %@", err]; NSLog(@"%@",str); } - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { NSLog(@"Received notification: %@", userInfo); //[self addMessageFromRemoteNotification:userInfo]; NSSsortingng* alertValue = [[userInfo valueForKey:@"aps"] valueForKey:@"badge"]; NSLog(@"my message-- %@",alertValue); badgeValue= [alertValue intValue]; [UIApplication sharedApplication].applicationIconBadgeNumber += badgeValue; //badgeValue = [UIApplication sharedApplication].applicationIconBadgeNumber; //[UIApplication sharedApplication].applicationIconBadgeNumber=0; //[[UIApplication sharedApplication] setApplicationIconBadgeNumber:badgeValue]; } 

Apple ne tient pas count de vos données pour vous. Cela montre seulement ce que vous dites. Ainsi, vous devez stocker le count sur votre server, puis indiquer à Apple le nouveau numéro de badge lorsque vous envoyez l'alerte. Généralement, cela se fait en ayant le téléphone de l'application à la maison lorsqu'il est lancé en disant à vos servers de mettre à zéro le nombre de notifications non lues.