Oracle Help Center | Oracle Responsys Mobile App Platform Cloud Service title

Displaying Alerts While App Is Running

By default, iOS does not display incoming push notifications while the mobile app is running 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 #available(iOS 10.0, *){
    PushIOManager.sharedInstance().notificationPresentationOptions = [UNNotificationPresentationOptions.alert,UNNotificationPresentationOptions.sound,UNNotificationPresentationOptions.badge]

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];
if let payload = userInfo["aps"]{
    if let alertMessage = (payload as AnyObject).object(forKey: "alert") as! String?{
        let alertView: UIAlertController = UIAlertController(title: "Alert", message: alertMessage, preferredStyle: UIAlertControllerStyle.alert)
        let cancelAction:UIAlertAction  = UIAlertAction(title: "OK", style: UIAlertActionStyle.cancel, handler: nil)
        self.window?.rootViewController?.present(alertView, animated: true, completion: nil)

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