iOS SDK API
SDK Interface Description
- MTMAService, which contains all the interfaces of the SDK.
- MTMAConfig, the application configuration information class.
- MTMAUserID, the user identification model.
- MTMAUserContact, the user contact information model.
- 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
- Interface Description:
Call Example
MTMAConfig *config = [[MTMAConfig alloc] init];
[MTMAService start:config];
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.
- Interface Description:
Call Example
MTMAUserContact *contact = [[MTMAUserContact alloc] init];
contact.contacts = @{@"Work Mobile Phone":@"13*********"};
contact.completion = ^(NSInteger code, NSString * _Nonnull message) { };
[MTMAService setUserContact:contact];
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
- Interface Description:
Call Example
MTMAEventObject *object = [[MTMAEventObject alloc] init];
object.eventName = @"sndefineevent2";
object.property = @{
@"key1":@"value1",
@"key2":@"value2",
};
[MTMAService eventRecord:object];
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.
- Interface Description:
Call Example
MTMAUserID *userid = [[MTMAUserID alloc] init];
userid.anonymousID = @"xxx";
userid.userID = @"xxx";
[MTMAService identifyAccount:userid];
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)
- Interface Description:
Call Example
[MTMAService setReportInterval:10];
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
- Interface Description:
Call Example
[MTMAService setMaxEventCacheCount:50];
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)
- Interface Description:
Call Example
[MTMAService setNoActiveSessionEndDurationTime:50];
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.
- Interface Description:
Call Example
[MTMAService EUID];
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
- 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:
- Interface Description:
Call Example
[MTMAService setUtmProperties:@{@"utm_source":@"value"}];
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:
- Interface Description:
[MTMAService setProperty:@{@"key":@"value"} completion:^(NSInteger code, NSString * _Nonnull message) {
}];
- + (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:
- Interface Description:
[MTMAService setProperty:@"key" to:@"value" completion:^(NSInteger code, NSString * _Nonnull message) {
}];
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:
- Interface Description:
[MTMAService increaseProperty:@"key" by:@(2) completion:^(NSInteger code, NSString * _Nonnull message) {
}];
- **+ (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:
- Interface Description:
[MTMAService increaseProperty:@{@"key1":@(5),@"key2":@(3)} completion:^(NSInteger code, NSString * _Nonnull message) {
}];
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:
- Interface Description:
[MTMAService addProperty:@"key" by:@[@"value"] completion:^(NSInteger code, NSString * _Nonnull message) {
}];
- **+ (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:
- Interface Description:
[MTMAService addProperty:@{@"key1":@[@"value"],@"key2":@[@"value"]} completion:^(NSInteger code, NSString * _Nonnull message) {
}];
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:
- Interface Description:
[MTMAService removeProperty:@"key" by:@[@"value"] completion:^(NSInteger code, NSString * _Nonnull message) {
}];
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.
- Interface Description:
Call Example
[MTMAService deleteProperty:@"key" completion:^(NSInteger code, NSString * _Nonnull message) {
}];
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.
- Interface Description:
Call Example
MTMACollectControl *collectControl = [[MTMACollectControl alloc] init];
collectControl.idfa = YES;
collectControl.idfv = YES;
collectControl.carrier = YES;
[MTMAService setCollectControl:collectControl];
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. |