我正在制作一个使用苹果推送通知的应用程序。当我的应用程序处于后台状态时,我能够以横幅的形式接收通知,但是当我的应用程序处于活动状态时,我能够显示您已通过此代码收到通知的警报:-
(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
}
}
但我想将通知显示为横幅。我会为此做些什么?请建议。