MoEngageInAppController

@objc
public class MoEngageInAppController : NSObject, MoEngageInAppActionHandlerDelegate
extension MoEngageInAppController: MoEngageTestInAppProtocol
extension MoEngageInAppController: MoEngageTriggerEvaluationCallBacksHandler

MoEngageInAppActionHandlerDelegate

Global Delay Check

  • Check if global delay between InApps has been satisfied

    Declaration

    Swift

    @objc
    public func checkGlobalDelayForInApps() -> Bool

    Return Value

    true if global delay check passed, false otherwise

Campaign Expiry Check

  • Check if campaign has expired

    Declaration

    Swift

    @objc
    public func checkCampaignExpiry(for campaign: MoEngageInAppCampaignMeta) -> Bool

    Parameters

    campaign

    The campaign to check

    Return Value

    true if campaign is not expired, false if expired

Context Check

  • Check if campaign contexts match current app contexts

    Declaration

    Swift

    @objc
    public func checkContexts(for campaign: MoEngageInAppCampaignMeta) -> Bool

    Parameters

    campaign

    The campaign to check

    Return Value

    true if context check passed, false otherwise

Screen Check

  • Check if campaign should be shown on current screen

    Declaration

    Swift

    @objc
    public func checkShowInScreen(for campaign: MoEngageInAppCampaignMeta) -> Bool

    Parameters

    campaign

    The campaign to check

    Return Value

    true if screen check passed, false otherwise

Orientation Check

  • Check if current device orientation is supported by the campaign

    Declaration

    Swift

    @objc
    public func checkIfCurrentOrientationIsSupported(_ campaignOrientationType: MoEngageInAppOrientationType) -> Bool

    Parameters

    campaignOrientationType

    The orientation type supported by the campaign

    Return Value

    true if orientation is supported, false otherwise

State Instance Check

  • Check campaign state instance for persistence, max times shown, and campaign-level delay. Validates campaign against stored state to determine if it can be shown again.

    Declaration

    Swift

    @objc
    public func checkWithStateInstance(for campaign: MoEngageInAppCampaignMeta, isPrioratizingStage: Bool) -> Bool

    Parameters

    campaign

    The campaign to check

    isPrioratizingStage

    Whether this is the priority stage (affects stat tracking)

    Return Value

    true if all state checks pass and campaign can be shown, false otherwise

InApp Enabled Check

  • Check if InApp is enabled (SDK enabled, not disabled by developer, config API enabled, user registered)

    Declaration

    Swift

    @objc
    public func isInAppEnabled() -> Bool

    Return Value

    true if InApp is enabled, false otherwise

Should Show InApp Check

  • Check if InApp should be shown (enabled and sync completed)

    Declaration

    Swift

    @objc
    public func shouldShowInApp() -> Bool

    Return Value

    true if InApp should be shown, false otherwise

Composite Rule Check (without explicit trigger type)

  • Check if all rules are satisfied for an InApp campaign. Performs FC check followed by non-FC rules (nudge, push opt-in, delay, expiry, screen, context, orientation, state).

    Declaration

    Swift

    @objc
    public func checkIfRulesSatisfied(
        for campaign: MoEngageInAppCampaignMeta,
        inPrioratizingStage isPrioratizingStage: Bool
    ) -> Bool

    Parameters

    campaign

    The campaign to check

    isPrioratizingStage

    Whether this is the priority stage (affects stat tracking)

    Return Value

    true if all rules pass and campaign is eligible to show, false otherwise

Composite Rule Check (with explicit trigger type)

  • Check if all rules are satisfied for an InApp campaign with explicit trigger type. Performs FC check with specified trigger type followed by non-FC rules.

    Declaration

    Swift

    @objc
    public func checkIfRulesSatisfied(
        for campaign: MoEngageInAppCampaignMeta,
        triggerType: Int,
        inPrioratizingStage isPrioratizingStage: Bool
    ) -> Bool

    Parameters

    campaign

    The campaign to check

    triggerType

    The explicit trigger type for FC evaluation

    isPrioratizingStage

    Whether this is the priority stage (affects stat tracking)

    Return Value

    true if all rules pass and campaign is eligible to show, false otherwise

Confirmance to test inapp protocol

Orientation

  • Handles orientation change for all visible nudges. Dismisses nudges that do not support the current orientation; repositions HTML nudges that do. Call this when the device orientation changes (e.g. from your app’s orientation handler).

    Declaration

    Swift

    @objc
    public func handleOrientationChangedForNudges()
  • Returns the nudge container view currently displayed for the given campaign, if any.

    Declaration

    Swift

    @objc
    public func getNudgeView(withCampaignID cid: String?) -> MoEngageInAppPrimaryContainerView?

    Parameters

    cid

    Campaign ID of the nudge.

    Return Value

    The nudge view for that campaign, or nil if not found or no nudges are visible.

Auto-dismiss and dismiss nudge

  • Dismisses the given nudge view: cancels any pending auto-dismiss timer, runs the remove animation, then removes it from nudgeViewsArray.

    Declaration

    Swift

    @objc
    public func dismissNudgeView(_ nudgeView: MoEngageInAppPrimaryContainerView?)

    Parameters

    nudgeView

    The nudge container view to dismiss; no-op if nil.

Create HTML nudge view

  • Creates an HTML nudge container: downloads template assets, checks keyboard visibility (and aborts if visible), builds the container with calculated frame, and loads the HTML.

    Declaration

    Swift

    @objc
    public func createHTMLNudgeView(withTemplatePayload templatePayload: MoEngageInAppViewPayload,
                                    isTestCampaign: Bool,
                                    withCompletionBlock completionBlock: @escaping (MoEngageInAppPrimaryContainerView?, MoEngageInAppViewPayload?) -> Void)

    Parameters

    templatePayload

    The in-app view payload for the HTML nudge.

    isTestCampaign

    If true, shows an alert on creation failure (e.g. for preview).

    completionBlock

    Called with the created nudge view and payload on success, or (nil, nil) on failure or when keyboard is visible.

Self-handled API

  • Fetches the next eligible self-handled campaign (respecting FC and display rules), applies delay, runs final rule check, and returns campaign info via the completion block. If InApps are disabled, sync is in progress, or no eligible campaign exists, the completion is called with (nil, accountMeta).

    Declaration

    Swift

    @objc
    public func getSelfHandledInApp(completionBlock: @escaping (MoEngageInAppSelfHandledCampaign?, MoEngageAccountMeta?) -> Void)

    Parameters

    completionBlock

    Called with the self-handled campaign info and account meta, or (nil, accountMeta) if none available or rules fail.

  • Builds a self-handled campaign info object from a view payload (content, display rules, context, expiry, etc.) for delegate callbacks and tracking.

    Declaration

    Swift

    @objc
    public func getSelfHandledInfo(forInAppPayload inAppPayload: MoEngageInAppViewPayload) -> MoEngageInAppSelfHandledCampaign

    Parameters

    inAppPayload

    The in-app view payload (e.g. from a fetched template).

    Return Value

    A MoEngageInAppSelfHandledCampaign instance with content, display rules, campaign ID/name, expiry, and context.

  • Call when the app has displayed the self-handled in-app. Tracks impression (analytics, FC increment, and state update).

    Declaration

    Swift

    @objc
    public func selfHandledShown(withCampaignInfo campaignInfo: MoEngageInAppSelfHandledCampaign)

    Parameters

    campaignInfo

    The self-handled campaign that was shown (from getSelfHandledInApp or built via MoEngageInAppSelfHandledCampaign(from:)).

  • Call when the user tapped/clicked the self-handled in-app. Tracks the in-app clicked analytics event.

    Declaration

    Swift

    @objc
    public func selfHandledClicked(withCampaignInfo campaignInfo: MoEngageInAppSelfHandledCampaign)

    Parameters

    campaignInfo

    The self-handled campaign that was clicked.

  • Call when the app dismissed the self-handled in-app. Tracks the in-app dismissed analytics event.

    Declaration

    Swift

    @objc
    public func selfHandledDismissed(withCampaignInfo campaignInfo: MoEngageInAppSelfHandledCampaign)

    Parameters

    campaignInfo

    The self-handled campaign that was dismissed.

Trigger evaluation & fetch

  • Fetches the template for the triggered campaign, applies display delay, then runs final rule check and shows the in-app (popup, nudge, or self-handled) via processFetchedTriggeredPayload.

    Declaration

    Swift

    @objc
    public func fetchTriggeredInApp(_ eligibleCampaign: MoEngageInAppCampaignMeta, withEventInfoDict triggerDict: [String : Any])

    Parameters

    eligibleCampaign

    Campaign meta for the triggered in-app.

    triggerDict

    Event info dictionary (event name, attributes, time) for the trigger payload.

  • Builds the attributes dictionary for the trigger payload by merging EVENT_ATTRS and converting timestamps in EVENT_ATTRS_CUST to ISO8601 strings.

    Declaration

    Swift

    @objc
    public func getAttributesDictForTrigger(withEventDict eventDict: [AnyHashable : Any]?) -> [String : Any]

    Parameters

    eventDict

    Raw event dict that may contain EVENT_ATTRS and EVENT_ATTRS_CUST (with optional timestamp array).

    Return Value

    A flattened attribute dictionary suitable for the trigger payload.

Final rule check for non-intrusive campaigns (migrated from Obj-C)

  • Performs final rule check (e.g. FC at impression stage) for a non-intrusive campaign, then calls the completion with the (possibly nil) view and payload. Used by Objective-C callers; block pointers are updated when rules fail.

    Declaration

    Swift

    @objc(performFinalRuleCheckForNonIntrusiveCampaign:blockInAppView:blockCampaignPayload:completionBlock:continuation:)
    public func performFinalRuleCheckForNonIntrusiveCampaign(
        _ payload: MoEngageInAppViewPayload,
        blockInAppView: UnsafeMutablePointer<MoEngageInAppPrimaryContainerView?>,
        blockCampaignPayload: UnsafeMutablePointer<MoEngageInAppViewPayload?>,
        completionBlock: (MoEngageInAppPrimaryContainerView?, MoEngageInAppViewPayload?) -> Void,
        continuation: MoEngageDelayedOperation.Continuation
    ) -> Bool

    Parameters

    payload

    Campaign payload to check.

    blockInAppView

    Pointer to in-app view; set to nil if rules fail.

    blockCampaignPayload

    Pointer to campaign payload; set to nil if rules fail.

    completionBlock

    Called with current view and payload after the check.

    continuation

    Delay manager continuation; always fulfilled before return.

    Return Value

    true if final rules passed, false otherwise.

  • Performs final rule check for a non-intrusive campaign and, if passed, attaches the nudge view on the main queue. Used by the triggered in-app flow when the payload is non-intrusive (nudge).

    Declaration

    Swift

    @objc(performFinalRuleCheckForNonIntrusiveCampaignWithAttachment:inAppView:continuation:)
    public func performFinalRuleCheckForNonIntrusiveCampaign(
        withAttachment payload: MoEngageInAppViewPayload,
        inAppView: MoEngageInAppPrimaryContainerView,
        continuation: MoEngageDelayedOperation.Continuation
    ) -> Bool

    Parameters

    payload

    Campaign payload to check.

    inAppView

    Nudge view to attach if rules pass.

    continuation

    Delay manager continuation; always fulfilled before return.

    Return Value

    true if final rules passed, false otherwise.

MoEngageTriggerEvaluationCallBacksHandler (trigger evaluator callbacks)

  • Called when trigger condition validation finished successfully; forwards to handleTriggerEvent and logs the result.

    Declaration

    Swift

    public func didFinishTriggerConditionValidation(for campaignId: String,
                                                    with result: MoEngageTriggerEvaluationResult)

    Parameters

    campaignId

    Campaign ID that completed validation (may be nil).

    result

    Evaluation result containing campaign IDs, event names, and attributes.

  • Called when the secondary trigger path timed out without completion; tracks evaluation-path expiry stat for the campaign.

    Declaration

    Swift

    public func didTimeoutSecondaryWihoutPathCompletion(campaignId: String)

    Parameters

    campaignId

    Campaign ID whose secondary path timed out.

  • Called when the trigger path was satisfied while the app was in the background; tracks “user not on app” stat for the campaign.

    Declaration

    Swift

    public func pathSatisfiedWhenUserWasOnBckground(campaignId: String)

    Parameters

    campaignId

    Campaign ID whose path was satisfied in background.

  • Called when trigger evaluation failed for a campaign. If the campaign is the current test in-app, tracks a test in-app “condition failed” event.

    Declaration

    Swift

    public func triggerEvaluationFailed(for campaignData: MoEngageTriggeredCampaignData)

    Parameters

    campaignData

    Triggered campaign data (campaign ID, event name, attributes) for the failed evaluation.

Utils & InApp State

  • Declaration

    Swift

    @objc
    public func getActionHandler() -> MoEngageInAppActionHandler

View Lookup

Nudge UI Logic

  • Calculate the frame for a HTML nudge based on its payload and position

    Declaration

    Swift

    @objc
    public static func calculateNudgeFrame(_ payload: MoEngageInAppViewPayload) -> CGRect

    Parameters

    payload

    The InApp view payload containing style and position information

    Return Value

    The calculated CGRect for the nudge