アップルプッシュ通知を使用しているアプリを作成しています。アプリがバックグラウンド状態の場合、バナーとして通知を受け取ることができますが、アプリがアクティブ状態の場合、このコードを介して通知を受け取ったことを示すアラートを表示できます:-
(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
NSString *cancelTitle = @"Close";
NSString *showTitle = @"Show";
NSString *message = [[userInfo valueForKey:@"aps"] valueForKey:@"alert"];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Some title"
message:message
delegate:self
cancelButtonTitle:cancelTitle
otherButtonTitles:showTitle, nil];
[alertView show];
} else {
//Do stuff that you would do if the application was not active
}
}
しかし、私は通知をバナーとして表示したいと思います。私はそれのために何をしますか?提案してください。