iOS Modal Rich Media

Send Modal Rich Media to iOS users

Starting from Pushwoosh SDK version 6.7.5, you have the ability to send Modal Rich Media.

We are introducing new Modal Rich Media, which can be customized. The new Modal Rich Media do not completely block the screen and can be positioned in different parts of the screen (top, bottom, and center).

For more information on Rich Media pages, please refer to our guide.

Configuration

By default, the Pushwoosh iOS SDK supports displaying legacy rich media.

  1. To enable the display of Modal Rich Media, set the parameter Pushwoosh_RICH_MEDIA_STYLE in your info.plist and assign it the value MODAL_RICH_MEDIA.

<key>Pushwoosh_RICH_MEDIA_STYLE</key>
<string>MODAL_RICH_MEDIA</string>
  1. By default, modal rich media will be displayed in the center of the screen with a bottom-to-top appearance animation.

  1. To configure the display of modal rich media (screen position, show animation, close animation), you need to use the method presented below.

// Modal Rich Media Configuration
PWModalWindowConfiguration.shared().configureModalWindow(with: .PWModalWindowPositionCenter,
                                                                 present: .PWAnimationPresentFromBottom,
                                                                 dismiss: .PWAnimationDismissUp)

Modal Rich Media can be positioned in three locations: top, bottom, or center.

typedef NS_ENUM(NSInteger, ModalWindowPosition) {
    PWModalWindowPositionTop,       // Toast appears at the top of the screen
    PWModalWindowPositionCenter,    // Toast appears at the center of the screen
    PWModalWindowPositionBottom,    // Toast appears at the bottom of the screen
    
    /**
     * Default position is the center of the screen.
     */
    PWModalWindowPositionDefault
};

The example below shows a modal rich media displayed at the top of the screen.

Modal Rich Media show animations include:

typedef NS_ENUM(NSInteger, PresentModalWindowAnimation) {
    PWAnimationPresentFromBottom,
    PWAnimationPresentFromTop,
    PWAnimationPresentFromRight,
    PWAnimationPresentFromLeft,
    PWAnimationPresentNone
};

Modal Rich Media close animations include:

typedef NS_ENUM(NSInteger, DismissModalWindowAnimation) {
    PWAnimationDismissDown,
    PWAnimationDismissUp,
    PWAnimationDismissLeft,
    PWAnimationDismissRight,
    PWAnimationCurveEaseInOut,
    PWAnimationDismissNone,
    
    /**
     * Default dismiss animation is `PWAnimationCurveEaseInOut`
     */
    PWAnimationDismissDefault
};

The example below demonstrates displaying modal rich media at the bottom of the screen with a left-to-right show animation and a rightward close animation:

  1. Additional parameters for displaying Modal Rich Media include options like adding haptic feedback of type vibration, enabling swipe gestures, and setting an automatic close timer after a specified duration.

// Haptic Feedback Type
PWModalWindowConfiguration.shared().setPresent(.PWHapticFeedbackLight)

/**
enum HapticFeedbackType

typedef NS_ENUM(NSInteger, HapticFeedbackType) {
    PWHapticFeedbackLight,         // Light vibration feedback
    PWHapticFeedbackMedium,        // Medium vibration feedback
    PWHapticFeedbackHard,          // Strong vibration feedback
    
    /**
     * Vibration is off by default.
     */
    PWHapticFeedbackNone
};
*/

// Swipe directions
let directions: [NSNumber] = [
    NSNumber(value: DismissSwipeDirection.PWSwipeDismissDown.rawValue),
    NSNumber(value: DismissSwipeDirection.PWSwipeDismissUp.rawValue)
]
PWModalWindowConfiguration.shared().setDismissSwipeDirections(directions)

/**
typedef NS_ENUM(NSInteger, DismissSwipeDirection) {
    PWSwipeDismissDown,
    PWSwipeDismissUp,
    PWSwipeDismissLeft,
    PWSwipeDismissRight,
    PWSwipeDismissNone
};
*/

// Close Modal Rich Media after N seconds
PWModalWindowConfiguration.shared().closeModalWindow(after: 3)

Done!

Last updated