MoEngageSDKAnalytics

public class MoEngageSDKAnalytics: NSObject

Class to track data on the MoEngage Platform.

  • Singleton class instance

    Declaration

    Swift

    public static let sharedInstance = MoEngageSDKAnalytics()

Track App Status

  • This method tells the SDK whether it is a fresh install or an existing application was updated.

    Declaration

    Swift

    public func appStatus(_ appStatus: MoEngageAppStatus, forAppID appID: String? = nil)

    Parameters

    appStatus

    Enum of type MoEngageAppStatus

    appID

    MoEngage Account Identifier.

  • This method tells the default SDK instance whether it is a fresh install or an existing application was updated.

    Declaration

    Swift

    public func appStatus(_ appStatus: MoEngageAppStatus)

    Parameters

    appStatus

    Enum of type MoEngageAppStatus

Track Event

Flush Events

  • Sync the tracked events instantaneously for Secondary instance

    Declaration

    Swift

    public func flush(forAppID appID: String? = nil, withCompletionBlock completionBlock: ((Bool) -> Void)? = nil)

    Parameters

    appID

    MoEngage Account Identifier.

    completionBlock

    completion block to be called after events are flushed out

  • Sync the tracked events instantaneously for Default instance

    Declaration

    Swift

    public func flush()
  • Sync the tracked events instantaneously for Secondary instance

    Declaration

    Swift

    public func flush(forAppID appID: String? = nil)

    Parameters

    appID

    MoEngage Account identifier

  • Sync the tracked events instantaneously for Default instance

    Declaration

    Swift

    public func flush(withCompletionBlock completionBlock: ((Bool) -> Void)? = nil)

    Parameters

    completionBlock

    completion block to be called after events are flushed out

User Attributes

  • Set custom user attribute for Secondary instance

    Declaration

    Swift

    public func setUserAttribute(_ value: Any?, withAttributeName attributeName: String, forAppID appID: String? = nil)

    Parameters

    value

    attribute value

    attributeName

    attribute name

    appID

    MoEngage account identifier

  • Set custom user attribute for Default instance

    Declaration

    Swift

    public func setUserAttribute(_ value: Any?, withAttributeName attributeName: String)

    Parameters

    value

    attribute value

    attributeName

    attribute name

  • Set epoch time for Secondary instance

    Declaration

    Swift

    public func setUserAttributeEpochTime(_ dateEpoch: Double, withAttributeName attributeName: String, forAppID appID: String? = nil)

    Parameters

    dateEpoch

    Epoch date of type double

    attributeName

    attribute name of type String

    appID

    MoEngage account identifier

  • Set epoch time for Default instance

    Declaration

    Swift

    public func setUserAttributeEpochTime(_ dateEpoch: Double, withAttributeName attributeName: String)

    Parameters

    dateEpoch

    Epoch date of type double

    attributeName

    attribute name of type String

  • Set User attribute date for Secondary instance

    Declaration

    Swift

    public func setUserAttributeDate(_ date: Date, withAttributeName attributeName: String, forAppID appID: String? = nil)

    Parameters

    date

    attribute value as Date

    attributeName

    attribute name

    appID

    MoEngage account identifier

  • Set User attribute date for Default instance

    Declaration

    Swift

    public func setUserAttributeDate(_ date: Date, withAttributeName attributeName: String)

    Parameters

    date

    attribute value as Date

    attributeName

    attribute name

  • Set User attribute ISO date for Secondary instance

    Note

    ISO accepted formats are yyyy-MM-dd’T'HH:mm:ss'Z’/yyyy-MM-dd’T'HH:mm:ss.SSS'Z’

    Declaration

    Swift

    public func setUserAttributeISODate(_ dateString: String, withAttributeName attributeName: String, forAppID appID: String? = nil)

    Parameters

    dateStr

    ISO date of type string

    attributeName

    attribute name

    appID

    MoEngage account identifier

  • Set User attribute ISO date

    Note

    ISO accepted formats are yyyy-MM-dd’T'HH:mm:ss'Z’/yyyy-MM-dd’T'HH:mm:ss.SSS'Z’

    Declaration

    Swift

    public func setUserAttributeISODate(_ dateString: String, withAttributeName attributeName: String)

    Parameters

    dateString

    ISO date of type string

    attributeName

    attribute name

  • Set custom user location for Secondary instance

    Declaration

    Swift

    public func setLocation(_ location: MoEngageGeoLocation, withAttributeName attributeName: String, forAppID appID: String? = nil)

    Parameters

    location
    attributeName

    attribute name

    appID

    MoEngage Account Identifier

  • Set custom user location

    Declaration

    Swift

    public func setLocation(_ location: MoEngageGeoLocation, withAttributeName attributeName: String)

    Parameters

    location
    attributeName

    attribute name

  • Set an Alias to update the existing Unique Id for Secondary instance

    Declaration

    Swift

    public func setAlias(_ alias: String, forAppID appID: String? = nil)

    Parameters

    alias

    identifier

    appID

    MoEngage Account Identifier

  • Set an Alias to update the existing Unique Id for Default instance

    Declaration

    Swift

    public func setAlias(_ alias: String)

    Parameters

    alias

    identifier

  • Set unique ID for Secondary instance

    Declaration

    Swift

    public func setUniqueID(_ uniqueID: String, forAppID appID: String? = nil)

    Parameters

    uniqueID

    Unique ID

    appID

    MoEngage Account identifier

  • Set unique ID for Default instance

    Declaration

    Swift

    public func setUniqueID(_ uniqueID: String)

    Parameters

    uniqueID

    Unique ID

  • Set Email ID for Secondary instance

    Declaration

    Swift

    public func setEmailID(_ emailID: String, forAppID appID: String? = nil)

    Parameters

    emailID

    emailID value.

    appID

    MoEngage Account identifier

  • Set Email ID

    Declaration

    Swift

    public func setEmailID(_ emailID: String)

    Parameters

    emailID

    emailID value.

  • Set user name for Secondary instance

    Declaration

    Swift

    public func setName(_ userName: String, forAppID appID: String? = nil)

    Parameters

    userName

    User Name value passed by user

    appID

    MoEngage Account identifier

  • Set user name

    Declaration

    Swift

    public func setName(_ userName: String)

    Parameters

    userName

    User Name value passed by user

  • Set User first name for Secondary instance

    Declaration

    Swift

    public func setFirstName(_ firstName: String, forAppID appID: String? = nil)

    Parameters

    firstName

    First Name value passed by user

    appID

    MoEngage Account identifier

  • Set User first name

    Declaration

    Swift

    public func setFirstName(_ firstName: String)

    Parameters

    firstName

    First Name value passed by user

  • Set User last name for Secondary instance

    Declaration

    Swift

    public func setLastName(_ lastName: String, forAppID appID: String? = nil)

    Parameters

    lastName

    Last Name value passed by user

    appID

    MoEngage Account identifier

  • Set User last name

    Declaration

    Swift

    public func setLastName(_ lastName: String)

    Parameters

    lastName

    Last Name value passed by user

  • Set mobile number for Secondary instance

    Declaration

    Swift

    public func setMobileNumber(_ mobileNum: String, forAppID appID: String? = nil)

    Parameters

    mobileNum

    Mobile Number value passed by user

    appID

    MoEngage Account identifier

  • Set mobile number

    Declaration

    Swift

    public func setMobileNumber(_ mobileNum: String)

    Parameters

    mobileNum

    Mobile Number value passed by user

  • Set User gender for Secondary instance

    Declaration

    Swift

    public func setGender(_ gender: MoEngageUserGender, forAppID appID: String? = nil)

    Parameters

    gender

    Gender value passed by user

    appID

    MoEngage Account identifier

  • Set User gender

    Declaration

    Swift

    public func setGender(_ gender: MoEngageUserGender)

    Parameters

    gender

    Gender value passed by user

  • Set User Date of Birth for Secondary instance

    Declaration

    Swift

    public func setDateOfBirth(_ dob: Date, forAppID appID: String? = nil)

    Parameters

    dob

    Date of Birth passed by user

    appID

    MoEngage Account identifier

  • Set User Date of Birth

    Declaration

    Swift

    public func setDateOfBirth(_ dob: Date)

    Parameters

    dob

    Date of Birth passed by user

  • Set user Date of Birth ISO format for Secondary instance

    Note

    ISO format accepted yyyy-MM-dd’T'HH:mm:ss.SSS'Z’ / yyyy-MM-dd’T'HH:mm:ss'Z’

    Declaration

    Swift

    public func setDateOfBirthInISO(_ dateString: String, forAppID appID: String? = nil)

    Parameters

    dateString

    attribute value accepted in ISO format

    appID

    MoEngage Account identifier

  • Method to set user date of birth ISO format

    Note

    ISO format accepted yyyy-MM-dd’T'HH:mm:ss.SSS'Z’ / yyyy-MM-dd’T'HH:mm:ss'Z’

    Declaration

    Swift

    public func setDateOfBirthInISO(_ dateString: String)

    Parameters

    dateString

    attribute value accepted in ISO format

  • Set user location for Secondary instance

    Declaration

    Swift

    public func setLocation(_ location: MoEngageGeoLocation, forAppID appID: String? = nil)

    Parameters

    location

    Location passed by user

    appID

    MoEngage Account identifier

  • Set user location

    Declaration

    Swift

    public func setLocation(_ location: MoEngageGeoLocation)

    Parameters

    location

    Location passed by user

  • Track user attribute push preference

    Declaration

    Swift

    public func trackUserPushPreference(_ isPushEnabled: Bool, forAppID appID: String? = nil)

    Parameters

    isPushEnabled

    true if Push is enabled else false.

    appID

    MoEngage Account identifier

Track Locale

  • Tracks device locale.

    Declaration

    Swift

    public func trackLocale()
  • Tracks device locale.

    Declaration

    Swift

    public func trackLocale(forAppID appID: String? = nil)

    Parameters

    appID

    MoEngage Account identifier

Reset User

  • Invalidates the existing sessions and user attributes and treats all actions performed by the user as a new user after this method is called

    Declaration

    Swift

    public func resetUser(forAppID appID: String? = nil, withCompletionBlock completionBlock: ((Bool) -> Void)? = nil)

    Parameters

    appID

    optional account identifier.

    completionBlock

    Returns true if reset is successful else false

  • Invalidates the existing sessions and user attributes and treats all actions performed by the user as a new user after this method is called

    Declaration

    Swift

    public func resetUser()
  • Invalidates the existing sessions and user attributes and treats all actions performed by the user as a new user after this method is called

    Declaration

    Swift

    public func resetUser(withCompletionBlock completionBlock: ((Bool) -> Void)? = nil)

    Parameters

    completionBlock

    Returns true if reset is successful else false

  • Invalidates the existing sessions and user attributes and treats all actions performed by the user as a new user after this method is called

    Declaration

    Swift

    public func resetUser(forAppID appID: String? = nil)

    Parameters

    appID

    MoEngage Account identifier

OptOut Methods

  • API to enable data tracking.

    Declaration

    Swift

    public func enableDataTracking(forAppID appID: String? = nil)

    Parameters

    appID

    MoEngage Account identifier

  • API to enable data tracking.

    Declaration

    Swift

    public func enableDataTracking()
  • Optionally opt-out of data tracking. When data tracking is opted out no custom event or user attribute is tracked on MoEngage Platform.

    Declaration

    Swift

    public func disableDataTracking(forAppID appID: String? = nil)

    Parameters

    appID

    MoEngage Account identifier

  • Optionally opt-out of data tracking. When data tracking is opted out no custom event or user attribute is tracked on MoEngage Platform.

    Declaration

    Swift

    public func disableDataTracking()
  • Enable IDFA tracking

    Declaration

    Swift

    public func enableIDFATracking(forAppID appID: String? = nil)

    Parameters

    appID

    MoEngage Account identifier

  • Enable IDFA tracking

    Declaration

    Swift

    public func enableIDFATracking()
  • Disable IDFA tracking

    Declaration

    Swift

    public func disableIDFATracking(forAppID appID: String? = nil)

    Parameters

    appID

    MoEngage Account identifier

  • Disable IDFA tracking

    Declaration

    Swift

    public func disableIDFATracking()
  • Enable IDFV tracking

    Declaration

    Swift

    public func enableIDFVTracking(forAppID appID: String? = nil)

    Parameters

    appID

    MoEngage Account identifier

  • Enable IDFV tracking

    Declaration

    Swift

    public func enableIDFVTracking()
  • Disable IDFV tracking

    Declaration

    Swift

    public func disableIDFVTracking(forAppID appID: String? = nil)

    Parameters

    appID

    MoEngage Account identifier

  • Disable IDFV tracking

    Declaration

    Swift

    public func disableIDFVTracking()

Process URL

  • Update source based on query params of the URL

    Declaration

    Swift

    public func processURL(_ url: URL?)

    Parameters

    url

    URL that contains source information in query params

Set Delegate

  • Set the Analytics delegate to get the callback for various Analytics events

    Declaration

    Swift

    public func setDelegate(delegate: MoEngageAnalyticsCallBack, forAppID appID: String? = nil)

    Parameters

    delegate

    Instance that confirms to MoEngageAnalyticsProtocol

    appID

    Optional Account Identifier