6
我們如何在應用程序圖標中獲取徽章通知,類似於tabbar項目中的徽章通知。我需要這個來通知新消息。iPhone應用程序中的應用程序圖標徽章
我們如何在應用程序圖標中獲取徽章通知,類似於tabbar項目中的徽章通知。我需要這個來通知新消息。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];
}