如何在应用程序的活动状态下将远程推送通知显示为横幅样式?

Sau*_*abh 6 iphone xcode objective-c push-notification ios

我正在制作一个应用程序,我正在使用苹果推送通知.当我的应用程序处于后台状态时,我可以收到通知作为横幅,但当我的应用程序处于活动状态时,我能够显示通过此代码收到通知的警报: -

(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
    }
}
Run Code Online (Sandbox Code Playgroud)

但我想把通知显示为横幅.我会为此做些什么?请建议.

rck*_*nes 2

您不能,如果您的应用程序处于活动状态(在前台运行),推送通知将直接发送到您的应用程序。通知中心不会处理该通知。

您必须自己实施某种横幅。