我正在从服务器端向 apns 服务器发送通知,我在处理徽章时遇到了一个小问题,如果用户在通知中心看到通知,我的徽章数量应该减少,如果应用程序已经在运行,我认为不需要徽章,但我的徽章号码总是“1”
从我的服务器端我发送徽章 =“1”。如何通知服务器我的应用程序具有特定的徽章编号,如何知道我的徽章编号。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
NSLog(@"%@",userInfo);
UIApplicationState state = [application applicationState];
[[UIApplication sharedApplication]setApplicationIconBadgeNumber:1];
if (state == UIApplicationStateActive) {
[[UIApplication sharedApplication]setApplicationIconBadgeNumber:0];
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@""
message:message
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alertView show];
[alertView release];
}
}