MoEngageInAppController
extension MoEngageInAppController
extension MoEngageInAppController: MoEngageTestInAppProtocol
extension MoEngageInAppController: MoEngageTriggerEvaluationCallBacksHandler
-
Check if global delay between InApps has been satisfied
Declaration
Swift
@objc public func checkGlobalDelayForInApps() -> BoolReturn Value
trueif global delay check passed,falseotherwise
-
Check if campaign has expired
Declaration
Swift
@objc public func checkCampaignExpiry(for campaign: MoEngageInAppCampaignMeta) -> BoolParameters
campaignThe campaign to check
Return Value
trueif campaign is not expired,falseif expired
-
Check if campaign contexts match current app contexts
Declaration
Swift
@objc public func checkContexts(for campaign: MoEngageInAppCampaignMeta) -> BoolParameters
campaignThe campaign to check
Return Value
trueif context check passed,falseotherwise
-
Check if campaign should be shown on current screen
Declaration
Swift
@objc public func checkShowInScreen(for campaign: MoEngageInAppCampaignMeta) -> BoolParameters
campaignThe campaign to check
Return Value
trueif screen check passed,falseotherwise
-
Check if current device orientation is supported by the campaign
Declaration
Swift
@objc public func checkIfCurrentOrientationIsSupported(_ campaignOrientationType: MoEngageInAppOrientationType) -> BoolParameters
campaignOrientationTypeThe orientation type supported by the campaign
Return Value
trueif orientation is supported,falseotherwise
-
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) -> BoolParameters
campaignThe campaign to check
isPrioratizingStageWhether this is the priority stage (affects stat tracking)
Return Value
trueif all state checks pass and campaign can be shown,falseotherwise
-
Check if InApp is enabled (SDK enabled, not disabled by developer, config API enabled, user registered)
Declaration
Swift
@objc public func isInAppEnabled() -> BoolReturn Value
trueif InApp is enabled,falseotherwise
-
Check if InApp should be shown (enabled and sync completed)
Declaration
Swift
@objc public func shouldShowInApp() -> BoolReturn Value
trueif InApp should be shown,falseotherwise
-
Check pre-conditions for showing InApps (screen blocking)
Declaration
Swift
@objc public func checkPreConditions( for campaigns: [MoEngageInAppCampaignMeta], withType sdkCmpType: MoEngageInAppSDKCampaignType, isPrioratizingStage: Bool ) -> BoolParameters
campaignsArray of campaigns to check
sdkCmpTypeThe SDK campaign type
isPrioratizingStageWhether this is the priority stage
Return Value
trueif pre-conditions are satisfied,falseotherwise
-
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 ) -> BoolParameters
campaignThe campaign to check
isPrioratizingStageWhether this is the priority stage (affects stat tracking)
Return Value
trueif all rules pass and campaign is eligible to show,falseotherwise
-
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 ) -> BoolParameters
campaignThe campaign to check
triggerTypeThe explicit trigger type for FC evaluation
isPrioratizingStageWhether this is the priority stage (affects stat tracking)
Return Value
trueif all rules pass and campaign is eligible to show,falseotherwise
-
Get eligible campaigns for multiple context validation
Declaration
Swift
@objc public func getEligibleCampaignForMultipleContext( _ campaignsArray: [MoEngageInAppCampaignMeta], forSDKCampaignType sdkCmpType: MoEngageInAppSDKCampaignType, inPrioratizingStage inPrioratizing: Bool ) -> [MoEngageInAppCampaignMeta]Parameters
campaignsArrayArray of campaigns to evaluate
sdkCmpTypeThe SDK campaign type
inPrioratizingWhether this is the priority stage
Return Value
Array of eligible campaigns
-
Get the most eligible campaign using default validation
Declaration
Swift
@objc public func getEligibleCampaign( _ campaignsArray: [MoEngageInAppCampaignMeta], forSDKCampaignType sdkCmpType: MoEngageInAppSDKCampaignType, inPrioratizingStage inPrioratizing: Bool ) -> MoEngageInAppCampaignMeta?Parameters
campaignsArrayArray of campaigns to evaluate
sdkCmpTypeThe SDK campaign type
inPrioratizingWhether this is the priority stage
Return Value
The most eligible campaign, or nil if none found
-
Core implementation for getting eligible campaigns with validation type. Performs precondition checks followed by rule evaluation for each campaign.
Declaration
Swift
@objc public func getEligibleCampaign( _ campaignsArray: [MoEngageInAppCampaignMeta], forSDKCampaignType sdkCmpType: MoEngageInAppSDKCampaignType, inPrioratizingStage inPrioratizing: Bool, validationType type: MoEngageInAppEligibleCriteria ) -> [MoEngageInAppCampaignMeta]Parameters
campaignsArrayArray of campaigns to evaluate (must be non-empty)
sdkCmpTypeThe SDK campaign type for logging
inPrioratizingWhether this is the priority stage (affects stat tracking)
typeThe validation type -
.multipleContextreturns all eligible,.defaultValidationreturns first matchReturn Value
Array of eligible campaigns (empty if none qualify or preconditions fail)
-
Declaration
Swift
public func addSessionTerminationEvent(for reason: MoEngageTestInAppSessionTermination)
-
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
cidCampaign ID of the nudge.
Return Value
The nudge view for that campaign, or
nilif not found or no nudges are visible. -
Attempts to show a non-intrusive nudge at the given position. If sync is still in progress, the position is cached and will be retried after sync. If an eligible campaign exists, it is fetched, delayed if needed, and attached.
Declaration
Swift
@objc public func showNudgeHelper(at nudgePosition: MoEngageNudgePosition)Parameters
nudgePositionPosition at which to show the nudge (e.g.
.top,.bottom,.bottomLeft,.bottomRight,.any).
-
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
nudgeViewThe nudge container view to dismiss; no-op if
nil.
-
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
templatePayloadThe in-app view payload for the HTML nudge.
isTestCampaignIf
true, shows an alert on creation failure (e.g. for preview).completionBlockCalled with the created nudge view and payload on success, or
(nil, nil)on failure or when keyboard is visible.
-
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
completionBlockCalled 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) -> MoEngageInAppSelfHandledCampaignParameters
inAppPayloadThe in-app view payload (e.g. from a fetched template).
Return Value
A
MoEngageInAppSelfHandledCampaigninstance 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
campaignInfoThe self-handled campaign that was shown (from
getSelfHandledInAppor built viaMoEngageInAppSelfHandledCampaign(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
campaignInfoThe 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
campaignInfoThe self-handled campaign that was dismissed.
-
Invoked when an event is tracked; evaluates trigger conditions and may show a triggered in-app.
Declaration
Swift
@objc public func eventTracked(withEventName event: String, andAttributes attrDict: [String : Any]?)Parameters
eventName of the tracked event.
attrDictOptional event attributes dictionary.
-
Evaluates trigger conditions for the given event. If InApp sync is not yet complete, the event is queued; otherwise matching campaigns are resolved and shown via
handleTriggerEvent.Declaration
Swift
@objc public func checkTriggerInApp(forEvent eventName: String?, withEventAttributes eventDict: [AnyHashable : Any]?)Parameters
eventNameName of the event; ignored if nil or empty.
eventDictEvent attributes (e.g. from analytics); may be nil.
-
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: [AnyHashable : Any])Parameters
eligibleCampaignCampaign meta for the triggered in-app.
triggerDictEvent info dictionary (event name, attributes, time) for the trigger payload.
-
Builds the attributes dictionary for the trigger payload by merging
EVENT_ATTRSand converting timestamps inEVENT_ATTRS_CUSTto ISO8601 strings.Declaration
Swift
@objc public func getAttributesDictForTrigger(withEventDict eventDict: [AnyHashable : Any]?) -> [String : Any]Parameters
eventDictRaw event dict that may contain
EVENT_ATTRSandEVENT_ATTRS_CUST(with optionaltimestamparray).Return Value
A flattened attribute dictionary suitable for the trigger payload.
-
performFinalRuleCheckForNonIntrusiveCampaign(_:blockInAppView: blockCampaignPayload: completionBlock: continuation: ) 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 ) -> BoolParameters
payloadCampaign payload to check.
blockInAppViewPointer to in-app view; set to nil if rules fail.
blockCampaignPayloadPointer to campaign payload; set to nil if rules fail.
completionBlockCalled with current view and payload after the check.
continuationDelay manager continuation; always fulfilled before return.
Return Value
trueif final rules passed,falseotherwise. -
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 ) -> BoolParameters
payloadCampaign payload to check.
inAppViewNudge view to attach if rules pass.
continuationDelay manager continuation; always fulfilled before return.
Return Value
trueif final rules passed,falseotherwise.
-
Called when trigger condition validation finished successfully; forwards to
handleTriggerEventand logs the result.Declaration
Swift
public func didFinishTriggerConditionValidation(for campaignId: String, with result: MoEngageTriggerEvaluationResult)Parameters
campaignIdCampaign ID that completed validation (may be nil).
resultEvaluation 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
campaignIdCampaign 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
campaignIdCampaign 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
campaignDataTriggered campaign data (campaign ID, event name, attributes) for the failed evaluation.
-
Check non-instrusive inapp specific eligibility condition.
Declaration
Swift
func isNudgeCampaignEligible( _ campaignMeta: MoEngageInAppCampaignMeta, inPrioratizingStage: Bool ) -> BoolParameters
campaignMetaThe campaign metadata to check.
inPrioratizingStageWhether check is in priority stage.
Return Value
Whether campaign passes check.
-
Declaration
Swift
func performMetaSync(inAppFetchType: MoEngageInAppSyncType, previousIdentities: [String : String], withCompletionBlock completionBlock: @escaping (Bool) -> Void) -
Declaration
Swift
func getSelfHandledInAppPostSync() -
Declaration
Swift
func getSelfHandledInAppsPostSync() -
Declaration
Swift
@nonobjc func fetchRequestBodyResult(inAppFetchType: MoEngageInAppSyncType, previousIdentities: [String : String]) -> MoEngageRequestBodyBuildResult? -
Declaration
Swift
func fetchRequestBodyResultForTemplateFetch() -> [String : Any] -
Declaration
Swift
func getQueryParamsForMultipleCampaignsInAppRequest() -> [String : String] -
Declaration
Swift
func getSelfHandledInApps(completionBlock: @escaping (MoEngageInAppSelfHandledData?) -> Void) -
Declaration
Swift
func fetchMultipleCampaignsInAppRequest(for campaigns: [MoEngageInAppCampaignMeta], withCompletionBlock completion: @escaping (Bool, [AnyHashable : Any]?) -> Void) -
Declaration
Swift
func createCampaignsRequestPayload(from campaigns: [MoEngageInAppCampaignMeta]) -> [[String : Any]] -
Declaration
Swift
func trackTestInAppEvent(for event: MoEngageTestInAppEvents, attributes: [String : Any]? = nil) -
Declaration
Swift
func trackTriggerTestInAppEvent(for event: MoEngageTestInAppEvents, triggerEvent: String, attributes: [String : Any]? = nil) -
Declaration
Swift
func setTestInAppDelegate() -
Declaration
Swift
func performNewTestInAppFlow(for inApp: [String : Any]) -
Declaration
Swift
func trackInAppStat(_ statType: MoEngageInAppStatType, for campaignId: String, highPriorityCampaignIds: [String]) -
Declaration
Swift
func trackInAppStat(_ statType: MoEngageInAppStatType, for campaignId: String) -
Check if the given campaign payload represents an HTML nudge
Declaration
Swift
func isHTMLNudgeCampaign(payload: MoEngageInAppViewPayload) -> BoolParameters
payloadThe campaign payload to check
Return Value
True if the campaign is an HTML nudge, false otherwise
-
Reposition HTML nudge when orientation changes
Declaration
Swift
func repositionHTMLNudge(_ nudgeView: MoEngageInAppPrimaryContainerView)Parameters
nudgeViewThe nudge view to reposition
-
Extract campaign IDs from an array of campaign metadata
Declaration
Swift
func getCampaignIDsFromCampaigns(_ campaigns: [MoEngageInAppCampaignMeta]) -> [String]Parameters
campaignsArray of campaign metadata
Return Value
Array of campaign ID strings
-
Check if segment re-evaluation meta sync should be performed based on 3-minute interval
Declaration
Swift
func shouldPerformSegmentReevalMetaSync() -> BoolReturn Value
trueif sync should be performed (first sync or > 3 minutes since last sync),falseotherwise -
Handle segment re-evaluation failure when backend returns 412 error with E002 code This method is called from Objective-C which has already validated the 412/E002 error
Declaration
Swift
func handleSegmentReevalFailure( campaignMeta: MoEngageInAppCampaignMeta, responseData: [AnyHashable: Any]? )Parameters
campaignMetaThe campaign metadata that failed segment re-evaluation
responseDataThe parsed error response dictionary from the server
-
Calculate the frame for a HTML nudge based on its payload and position
Declaration
Swift
@objc public static func calculateNudgeFrame(_ payload: MoEngageInAppViewPayload) -> CGRectParameters
payloadThe InApp view payload containing style and position information
Return Value
The calculated CGRect for the nudge
-
Sync session and clear counters if session changed (called from Objective-C)
Declaration
Swift
@objc public func syncAndClearSessionCountersIfNeeded() -
Call this from application lifecycle events
Declaration
Swift
@objc public func syncFCSessionOnAppForeground() -
Call this from application lifecycle events Per technical doc: “On App background - Trigger sync if any data sync is pending”
Declaration
Swift
@objc public func triggerFCsyncOnAppBackground()
-
Check FC rules for a campaign (main entry point called from Objective-C)
Declaration
Swift
@objc public func checkFCRulesForCampaign(_ campaign: MoEngageInAppCampaignMeta, isPrioratizingStage: Bool) -> BoolParameters
campaignThe campaign to check
isPrioratizingStageWhether this is in prioritizing stage
Return Value
True if FC rules allow the campaign, false otherwise
-
Check FC rules for a campaign with explicit trigger type (called from Objective-C)
Declaration
Swift
@objc public func checkFCRulesForCampaign(_ campaign: MoEngageInAppCampaignMeta, triggerType: NSInteger, isPrioratizingStage: Bool) -> BoolParameters
campaignThe campaign to check
triggerTypeThe explicit trigger type as NSInteger (for Objective-C compatibility)
isPrioratizingStageWhether this is in prioritizing stage
Return Value
True if FC rules allow the campaign, false otherwise
-
Re-evaluate FC for impression tracking (called from Objective-C)
Declaration
Swift
@objc public func reEvaluateFCForImpressionWithCampaign(_ campaign: MoEngageInAppCampaign) -> BoolParameters
campaignThe campaign to re-evaluate
Return Value
True if FC rules still allow the campaign, false otherwise
-
Increment FC counters after campaign is shown (called from Objective-C)
Declaration
Swift
@objc public func incrementFCCountersForCampaign(_ campaign: MoEngageInAppCampaign) -
Processes frequency data from template payload and ingests it into FC state manager.
Declaration
Swift
@objc public func processFrequencyDataFromPayload(_ payload: MoEngageInAppViewPayload)Parameters
payloadThe view payload containing frequency data