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

I am creating an application in which I am using push push notification. When my application is in the background, I receive a notification in the form of a banner, but when my application is in the active state, I can show a warning that you 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 the notification as a banner. What will I do for this? Please suggest.

+7
source share
1 answer

You cannot, if your application is active (running in the foreground), a push notification is sent directly to your application. The notification center will not process the notification.

You will need to implement some kind of banner.

+3
source

All Articles