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.

  • Is it possible to see the code generated by ARC at compile time?
  • Get Bundle ID from a different target
  • Use Xcode Auto Layout for different image sizes on iPhone
  • Is there any way to add constraint between a view and the top layout guide in a xib file?
  • extern NSString not accessible since Swift 2.2
  • Disable warnings in Xcode from frameworks
  • Solutions Collect From Internet About “How to show remote push notification as a banner style in active state of app?”

    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.