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()
-
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) throwsParameters
encoderThe 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) throwsParameters
decoderThe decoder to read data from.
-
Initializes the display rules from an NSCoder for unarchiving.
Declaration
Swift
required public init?(coder decoder: NSCoder)Parameters
decoderThe 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
encoderThe coder to use for archiving.