MoEngageInAppDisplayRules

@objcMembers
public class MoEngageInAppDisplayRules : NSObject, NSCoding, Codable

A class that defines display rules and conditions for in-app messages.

This class manages when and where in-app messages should be displayed based on screen contexts and screen names. It helps control the targeting and placement of in-app campaigns to ensure they appear at the right time and location. It conforms to NSCoding and Codable protocols for data persistence.

  • Array of context strings that were configured in the dashboard. These contexts help determine when the in-app message should be displayed.

    Declaration

    Swift

    public let contexts: [String]
  • Array of screen names where the in-app message should be displayed. The message will only be shown when the user is on one of these screens.

    Declaration

    Swift

    public let showInScreens: [String]
  • Default initializer for the display rules.

    Declaration

    Swift

    public override init()

Codable

  • Encodes the display rules to an encoder.

    Throws

    Encoding errors if the data cannot be encoded.

    Declaration

    Swift

    public func encode(to encoder: any Encoder) throws

    Parameters

    encoder

    The encoder to write data to.

  • Initializes the display rules from a decoder.

    Throws

    Decoding errors if the data is malformed.

    Compatibility Notes:

    • For SDK versions up to 9.21.0, screen names were stored as a single string
    • Current versions store screen names as an array of strings

    Declaration

    Swift

    public required init(from decoder: any Decoder) throws

    Parameters

    decoder

    The decoder to read data from.

NSCoding

  • Initializes the display rules from an NSCoder for unarchiving.

    Declaration

    Swift

    required public init?(coder decoder: NSCoder)

    Parameters

    decoder

    The coder to use for unarchiving.

    Return Value

    An initialized display rules instance.

  • Encodes the display rules using NSCoder for archiving.

    Declaration

    Swift

    public func encode(with encoder: NSCoder)

    Parameters

    encoder

    The coder to use for archiving.