iOS SDK API

Last updated:2025-03-18

SDK Interface Description

  1. MTMAService, which contains all the interfaces of the SDK.
  2. MTMAConfig, the application configuration information class.
  3. MTMAUserID, the user identification model.
  4. MTMAUserContact, the user contact information model.
  5. MTMACollectControl, the data collection control model.

Start the MA Business Function

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • + start:(MTMAConfig * )config;
    • Interface Description:
      • Enable the EngageLab MA function.
      • The start interface is the starting interface for other interfaces, so the start interface must be called first before other interfaces can be called.
    • Parameter Description
      • config configuration class

Call Example

MTMAConfig *config = [[MTMAConfig alloc] init]; [MTMAService start:config];
              MTMAConfig *config = [[MTMAConfig alloc] init];
    [MTMAService start:config];

        
This code block in the floating window

Set User Contact Information

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • + (void)setUserContact:(MTMAUserContact * )contact;
    • Interface Description:
      • Set the user contact information.
    • Parameter Description
      • contacts: Set multiple contact information. The key is the name of the contact information, and the value is the value of the contact information. Currently, 4 types of contact information are supported: email, mobile_phone, landline_phone, and whatsapp_phone.

Call Example

MTMAUserContact *contact = [[MTMAUserContact alloc] init]; contact.contacts = @{@"Work Mobile Phone":@"13*********"}; contact.completion = ^(NSInteger code, NSString * _Nonnull message) { }; [MTMAService setUserContact:contact];
              MTMAUserContact *contact = [[MTMAUserContact alloc] init];
    contact.contacts = @{@"Work Mobile Phone":@"13*********"};
    contact.completion = ^(NSInteger code, NSString * _Nonnull message) { };
    [MTMAService setUserContact:contact];

        
This code block in the floating window

Event Reporting

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • **+ (void)eventRecord:(MTMAEventObject )event;*
    • Interface Description:
      • Report an event.
    • Parameter Description
      • The event reporting model
      • eventName: The name of the reported event
      • property: Event properties, where the key is the property name and the value is the property value

Call Example

MTMAEventObject *object = [[MTMAEventObject alloc] init]; object.eventName = @"sndefineevent2"; object.property = @{ @"key1":@"value1", @"key2":@"value2", }; [MTMAService eventRecord:object];
              MTMAEventObject *object = [[MTMAEventObject alloc] init];
    object.eventName = @"sndefineevent2";
    object.property = @{
        @"key1":@"value1",
        @"key2":@"value2",
    };
    [MTMAService eventRecord:object];

        
This code block in the floating window

Set User Identification

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • + (void)identifyAccount:(MTMAUserID * )userID;
    • Interface Description:
      • Set the user identification.
    • Parameter Description
      • The user identification model
      • userID: Set the unique logged-in user identification here.
      • anonymousID: When the user is not logged in but other identifiable information is provided, it can be set as the anonymous ID, such as an email address or an identification ID generated by a third party.

Call Example

MTMAUserID *userid = [[MTMAUserID alloc] init]; userid.anonymousID = @"xxx"; userid.userID = @"xxx"; [MTMAService identifyAccount:userid];
              MTMAUserID *userid = [[MTMAUserID alloc] init];
    userid.anonymousID = @"xxx";
    userid.userID = @"xxx";
    [MTMAService identifyAccount:userid];

        
This code block in the floating window

Set the Report Interval of Uploaded Data

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • + (void)setReportInterval:(NSInteger)interval;
    • Interface Description:
      • Set the report interval of uploaded data. When this interface is not called, the event data is reported once every 10 seconds by default.
      • The report interval is cached in memory and needs to be called in each lifecycle of the application to take effect.
    • Parameter Description
      • interval The report interval, in s (seconds)

Call Example

[MTMAService setReportInterval:10];
              [MTMAService setReportInterval:10];

        
This code block in the floating window

Set the Upper Limit of Event Cache Entries

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • + (void)setMaxEventCacheCount:(NSInteger)count;
    • Interface Description:
      • Set the upper limit of the number of event cache entries, which is 50 by default and cannot exceed 500 at most.
      • When the cache quantity is exceeded, all data will be reported.
    • Parameter Description
      • count The upper limit of the number of event cache entries

Call Example

[MTMAService setMaxEventCacheCount:50];
              [MTMAService setMaxEventCacheCount:50];

        
This code block in the floating window

Set the Session Timeout

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • + (void)setNoActiveSessionEndDurationTime:(NSInteger)interval;
    • Interface Description:
      • Set the session timeout, which is 30 minutes by default.
      • When the App switches to the background, the session timeout timer starts. If there is no activity within the timeout period, the current session will end.
    • Parameter Description
      • interval The timeout duration, in s (seconds)

Call Example

[MTMAService setNoActiveSessionEndDurationTime:50];
              [MTMAService setNoActiveSessionEndDurationTime:50];

        
This code block in the floating window

Get EUID

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • + (NSString * )EUID;
    • Interface Description:
      • Get the EUID of EngageLab MA.

Call Example

[MTMAService EUID];
              [MTMAService EUID];

        
This code block in the floating window

Set UTM Properties

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • + (void)setUtmProperties:(NSDictionary * )property;
    • Interface Description:
      • UTM properties are standard event properties. If developers can identify which advertisement the user jumped from to access the App, it is recommended to set the UTM information, and we will pass this parameter when reporting events. Currently, the UTM properties that can be set are:
        • utm_source The source of the advertising campaign
        • utm_medium The medium of the advertising campaign
        • utm_term The term of the advertising campaign
        • utm_content The content of the advertising campaign
        • utm_campaign The name of the advertising campaign
        • utm_id The ID of the advertising campaign

Call Example

[MTMAService setUtmProperties:@{@"utm_source":@"value"}];
                 [MTMAService setUtmProperties:@{@"utm_source":@"value"}];

        
This code block in the floating window

Set User Properties

Overwrite and Update User Properties

  • + (void)setProperty:(NSDictionary * )userinfo completion:(void (^)(NSInteger code, NSString * message))completion;
    • Interface Description:
      • The content of these user properties is stored in an NSDictionary, where the key is the name of the user property and must be an NSString, and the value is the content of the user property, which only supports types such as NSString, NSNumber, NSSet, and NSArray.
      • Currently, the elements in the value of the NSSet or NSArray type only support being NSString.
      • If a certain user property already existed before, it will be overwritten this time; if it does not exist, it will be created. For example: the user's membership level.
    • Call Example:
[MTMAService setProperty:@{@"key":@"value"} completion:^(NSInteger code, NSString * _Nonnull message) { }];
             [MTMAService setProperty:@{@"key":@"value"} completion:^(NSInteger code, NSString * _Nonnull message) {
       
   }];

        
This code block in the floating window
  • + (void)setProperty:(NSString * )key to:(id)value completion:(void (^)(NSInteger code, NSString * message))completion;
    • Interface Description:
      • Set the content of a single user property of the user.
      • The content of these user properties is stored in an NSDictionary, where the key is the name of the user property and must be an NSString, and the value is the content of the user property, which only supports types such as NSString, NSNumber, NSSet, and NSArray.
      • Currently, the elements in the value of the NSSet or NSArray type only support being NSString.
      • If a certain user property already existed before, it will be overwritten this time; if it does not exist, it will be created. For example: the user's membership level.
    • Call Example:
[MTMAService setProperty:@"key" to:@"value" completion:^(NSInteger code, NSString * _Nonnull message) { }];
             [MTMAService setProperty:@"key" to:@"value" completion:^(NSInteger code, NSString * _Nonnull message) {
       
   }];

        
This code block in the floating window

Increment and Update User Properties

  • **+ (void)increaseProperty:(NSString )key by:(NSNumber )amount completion:(void (^)(NSInteger code, NSString * message))completion;
    • Interface Description:
      • Add a value to a numeric user property and accumulate all the reported data, such as the cumulative consumption amount.
      • This interface can only be called for user properties of the NSNumber type, otherwise it will be ignored. If this user property did not exist before, the initial value is treated as 0.
    • Call Example:
[MTMAService increaseProperty:@"key" by:@(2) completion:^(NSInteger code, NSString * _Nonnull message) { }];
              [MTMAService increaseProperty:@"key" by:@(2) completion:^(NSInteger code, NSString * _Nonnull message) {
    
    }];

        
This code block in the floating window
  • **+ (void)increaseProperty:(NSDictionary )userinfo completion:(void (^)(NSInteger code, NSString * message))completion;*
    • Interface Description:
      • Add values to multiple numeric user properties and accumulate all the reported data, such as the cumulative consumption amount.
      • This interface can only be called for user properties of the NSNumber type, otherwise it will be ignored. If this user property did not exist before, the initial value is treated as 0.
    • Call Example:
[MTMAService increaseProperty:@{@"key1":@(5),@"key2":@(3)} completion:^(NSInteger code, NSString * _Nonnull message) { }];
              [MTMAService increaseProperty:@{@"key1":@(5),@"key2":@(3)} completion:^(NSInteger code, NSString * _Nonnull message) {
    
    }];

        
This code block in the floating window

add User Properties

  • **+ (void)addProperty:(NSString )key by:(NSObject )content completion:(void (^)(NSInteger code, NSString * message))completion
    • Interface Description:
      • Add some values to a property of the NSSet or NSArray type.
      • As mentioned before, the elements of this NSSet or NSArray must be NSString, otherwise it will be ignored. At the same time, if the user property to be added did not exist before, an empty NSSet or NSArray will be initialized.
    • Call Example:
[MTMAService addProperty:@"key" by:@[@"value"] completion:^(NSInteger code, NSString * _Nonnull message) { }];
              [MTMAService addProperty:@"key" by:@[@"value"] completion:^(NSInteger code, NSString * _Nonnull message) {
    
    }];

        
This code block in the floating window
  • **+ (void)addProperty:(NSDictionary )userinfo completion:(void (^)(NSInteger, NSString * _Nonnull))completion;*
    • Interface Description:
      • Add some values to multiple properties of the NSSet or NSArray type.
      • As mentioned before, the elements of this NSSet or NSArray must be NSString, otherwise it will be ignored. At the same time, if the user property to be added did not exist before, an empty NSSet or NSArray will be initialized.
    • Call Example:
[MTMAService addProperty:@{@"key1":@[@"value"],@"key2":@[@"value"]} completion:^(NSInteger code, NSString * _Nonnull message) { }];
              [MTMAService addProperty:@{@"key1":@[@"value"],@"key2":@[@"value"]} completion:^(NSInteger code, NSString * _Nonnull message) {
    
    }];

        
This code block in the floating window

Remove User Properties

  • **+ (void)removeProperty:(NSString * )key by:(NSObject )content completion:(void (^)(NSInteger code, NSString * message))completion;*
    • Interface Description:
      • Delete some values from a property of the NSSet or NSArray type.
      • The parameter content is of the NSSet or NSArray type, and the elements inside must be NSString.
    • Call Example:
[MTMAService removeProperty:@"key" by:@[@"value"] completion:^(NSInteger code, NSString * _Nonnull message) { }];
              [MTMAService removeProperty:@"key" by:@[@"value"] completion:^(NSInteger code, NSString * _Nonnull message) {
    
    }];

        
This code block in the floating window

Delete User Properties

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • + (void)deleteProperty:(NSString * )key completion:(void (^)(NSInteger code, NSString * message))completion;
    • Interface Description:
      • Delete all the content of a certain user property.
      • If this user property did not exist before, it will be directly ignored.

Call Example

[MTMAService deleteProperty:@"key" completion:^(NSInteger code, NSString * _Nonnull message) { }];
              [MTMAService deleteProperty:@"key" completion:^(NSInteger code, NSString * _Nonnull message) {
        
    }];

        
This code block in the floating window

Data Collection Control

Supported Versions

The version when it starts to be supported: 5.0.0

Interface Definition

  • **+ (void)setCollectControl:(MTMACollectControl )control;*
    • Interface Description:
      • Control whether the data items in the MTMACollectControl class are collected.

Call Example

MTMACollectControl *collectControl = [[MTMACollectControl alloc] init]; collectControl.idfa = YES; collectControl.idfv = YES; collectControl.carrier = YES; [MTMAService setCollectControl:collectControl];
              MTMACollectControl *collectControl = [[MTMACollectControl alloc] init];
    collectControl.idfa = YES;
    collectControl.idfv = YES;
    collectControl.carrier = YES;
    [MTMAService setCollectControl:collectControl];

        
This code block in the floating window

MTMAConfig Class

The application configuration information class. The following is the description of the properties:

Parameter Name Parameter Type Parameter Description
userID MTMAUserID The user identification model. When this property is set, the user identification will be set during initialization.
completion (^)(NSInteger code, NSString * message) The request result callback, where code: 0 means success.

MTMAUserID Class

The user identification model class. The following is the description of the properties:

Parameter Name Parameter Type Parameter Description
userID NSString Set the unique logged-in user identification here.
anonymousID NSString When the user is not logged in but other identifiable information is provided, it can be set as the anonymous ID, such as an email address or an identification ID generated by a third party.
completion (^)(NSInteger code, NSString * message) The request result callback, where code: 0 means success.

MTMACollectControl Class

The user data collection control model class. The following is the description of the properties:

Parameter Name Parameter Type Parameter Description
idfa BOOL Whether to collect idfa information. Set to NO to not collect idfa information. The default is NO.
idfv BOOL Whether to collect idfv information. Set to NO to not collect idfv information. The default is NO.
carrier BOOL Whether to collect carrier information. Set to NO to not collect carrier information. The default is YES.

MTMAUserContact Class

The user channel model class. The following is the description of the properties:
If it is not set or set to nil, it is considered that there is no modification. When it is set to an empty string "", it is considered that the contact information is cleared.

Parameter Name Parameter Type Parameter Description
contacts NSDictionary The contact information dictionary, supporting 4 types of contact information: email, mobile_phone, landline_phone, and whatsapp_phone.
completion (^)(NSInteger code, NSString * message) The request result callback, where code: 0 means success.

MTMAEventObject Class

The custom event object class. The following is the description of the properties:

Parameter Name Parameter Type Parameter Description
eventName NSString The event ID, which is required and cannot be empty.
property NSDictionary<NSString *, id> Custom properties (less than or equal to 500). The key is an NSString and can only contain numbers, letters, and underscores; the value can be an NSString/NSNumber.
在文档中心打开
icon
Contact Sales