iPhone应用程序中的应用程序图标徽章
答
您可以设置应用程序图标的证件号码这样的:
[UIApplication sharedApplication].applicationIconBadgeNumber = 3;
答
如果你想要把通过PUSH消息证件号码,您可以发送PUSH为:
{"aps":{"alert":"My Push Message","sound":"default","badge",3}}
然后在您的AppDelegate中添加以下内容:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo{
// This get's the number you sent in the push and update your app badge.
[UIApplication sharedApplication].applicationIconBadgeNumber = [[userInfo objectForKey:@"badge"] integerValue];
// Shows an alert in case the app is open, otherwise it won't notify anything
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"New Notification!"
message:[[userInfo objectForKey:@"aps"] objectForKey:@"alert"] delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}