How to show remote push notification as a banner style in active state of app?

I am making an app in which I am using apple push notification. When my app is in background state then I am able to receive notification as a banner but when my app is in active state then I am able to show an alert that you have received a notification through this code : -

(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
    }
}

but I want to show notification as a banner. What I'll do for it? Please suggest.


You can't, if your app is active(running in the foreground) the push notification is directly send to your app. The notification center will not handle the notification.

You will have to implement some kind of banner your self.

链接地址: http://www.djcxy.com/p/11526.html

上一篇: Custom CallOut在ios6中显示不正确?

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