MoEngage

@objc
public class MoEngage : NSObject, @unchecked Sendable

This class handles MoEngage Initialization

  • Shared instance of MoEngage class

    Declaration

    Swift

    @objc
    public static var sharedInstance: MoEngage { get }

Default Instance Initialization

File Based Instance Initialization

Secondary Instance Initialization

SDK Enable/disable methods

  • API to enable SDK usage for the account configured as default.

    Declaration

    Swift

    @objc
    public func enableSDK()
  • API to enable SDK usage for the account for Secondary instance

    Declaration

    Swift

    @objc
    public func enableSDK(appId: String? = nil)

    Parameters

    appId

    MoEngage Account Identifier

  • API to disable all features of the SDK for the account configured as default.

    Declaration

    Swift

    @objc
    public func disableSDK()
  • API to disable all features of the SDK for Secondary instance

    Declaration

    Swift

    @objc
    public func disableSDK(appId: String? = nil)

    Parameters

    appId

    MoEngage Account Identifier

SDK Event Observer

  • Register an observer to receive SDK-autonomous events (e.g. background batch sync results) for a workspace. Observers are held strongly until unregisterSDKEventObserver is called or the instance is torn down. Call after SDK init for the target workspace.

    Note

    Registration is eventually consistent — the call hops to the instance actor before the observer is installed. An event fired in the small window immediately after this call returns may not reach the observer.

    Declaration

    Swift

    @objc
    public func registerSDKEventObserver(
        _ observer: MoEngageSDKEventObserver, forWorkspaceId workspaceId: String? = nil
    )

    Parameters

    observer

    The observer to register.

    workspaceId

    Target workspace; nil for the default instance.

  • Unregister a previously-registered observer. Removes a single registration; if the same observer was registered N times, paired unregister calls are needed.

    Declaration

    Swift

    @objc
    public func unregisterSDKEventObserver(
        _ observer: MoEngageSDKEventObserver, forWorkspaceId workspaceId: String? = nil
    )

    Parameters

    observer

    The observer to remove.

    workspaceId

    The workspace previously registered for; nil for default.

  • Async stream of SDK-autonomous events for the workspace. Concurrency-first counterpart to registerSDKEventObserver. Each stream is an independent consumer. Finishes when the instance is torn down; pre-init calls return an immediately-finished stream. Swift-only; ObjC consumers use the delegate API.

    Declaration

    Swift

    public func sdkEventStream(
        forWorkspaceId workspaceId: String? = nil
    ) -> AsyncStream<MoEngageSDKEvent>

    Parameters

    workspaceId

    Target workspace; nil for the default instance.