Oracle Help Center | Oracle Push Cloud Service (Standalone) title

Displaying Alerts While App Is Running

By default, iOS does not display incoming push notifications while the mobile app is in the foreground. You can modify your app to do so by following the instructions in this section.

If you are using iOS 10+ UserNotifications: You can instruct the SDK to show notifications even when your app is in the foreground, the same way as if it was in the background. It will follow the user's chosen presentation style; that is, by default it will slide down from the top.

To enable this behavior (disabled by default), add the following after you configured your SDK in didFinishLaunchingWithOptions in your AppDelegate.m file:

[PushIOManager sharedInstance].notificationPresentationOptions = UNNotificationPresentationOptionAlert|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionBadge;

If you are not yet using iOS 10+ UserNotifications: If you want to show an incoming push notification while your app is in the foreground, you must display an alert manually. Modify the following method in your AppDelegate.m file:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
  [[PushIOManager sharedInstance] didReceiveRemoteNotification:userInfo];

  NSDictionary *payload = [userInfo objectForKey:@"aps"];
  NSString *alertMessage = [payload objectForKey:@"alert"];
  UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:alertMessage delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

  [alertView show];
}

NOTE: This sample does not release the alertView instance. If your project is not using ARC, you will need to do so.