6
タブバーアイテムのバッジ通知と同様に、アプリアイコンでバッジ通知を受け取る方法を教えてください。私は新しいメッセージを知らせるためにこれを必要とします。iPhoneアプリのアプリアイコンのバッジ
タブバーアイテムのバッジ通知と同様に、アプリアイコンでバッジ通知を受け取る方法を教えてください。私は新しいメッセージを知らせるためにこれを必要とします。iPhoneアプリのアプリアイコンのバッジ
あなたはこのようにアプリのアイコンのバッジ番号を設定することができます。
{"aps":{"alert":"My Push Message","sound":"default","badge",3}}
:あなたはPUSHメッセージを介してバッジ番号を入れたい場合は、あなたのようにPUSHを送信することができ
[UIApplication sharedApplication].applicationIconBadgeNumber = 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];
}