集成指南
最新更新:2025-03-18
适用版本
v5.0.0 及以后版本。目前 SDK 只支持 iOS 10 以上版本的手机系统。
如需使用 EngageLab SDK 的 MA 功能,需要同时集成 AppPush 模块。请先在 AppPush 平台创建一个应用获得 AppKey。
配置工程
导入 SDK
Cocoapods 导入
pod 'MTMA'
注:如果无法导入最新版本,请执行 pod repo update master 这个命令来升级本机的 pod 库,然后重新 pod 'MTMA'
pod 'MTMA'
注:如果无法导入最新版本,请执行 pod repo update master 这个命令来升级本机的 pod 库,然后重新 pod 'MTMA'
此代码块在浮窗中显示
- 如果需要安装指定版本则使用以下方式(以 MTMA 5.0.0 版本为例):
pod 'MTMA', '5.0.0'
pod 'MTMA', '5.0.0'
此代码块在浮窗中显示
手动导入
- 将 SDK 包解压,在 Xcode 中选择 “Add files to 'Your project name'...”,将 MTMA-ios-x.x.x.xcframework 添加到你的工程目录中。
初始化 SDK
在 MTPush 初始化函数调用之后进行 MTMA SDK 的初始化
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 先初始化 Push sdk
NSString *advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
[MTPushService setupWithOption:launchOptions appKey:appKey
channel:channel
apsForProduction:isProduction
advertisingIdentifier:advertisingId];
// 再初始化 MTMA SDK
MTMAConfig *config = [[MTMAConfig alloc] init];
config.completion = ^(NSInteger code, NSString * _Nonnull message) {
NSLog(@"result:%ld - %@", code, message);
};
[MTMAService start:config];
}
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 先初始化 Push sdk
NSString *advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
[MTPushService setupWithOption:launchOptions appKey:appKey
channel:channel
apsForProduction:isProduction
advertisingIdentifier:advertisingId];
// 再初始化 MTMA SDK
MTMAConfig *config = [[MTMAConfig alloc] init];
config.completion = ^(NSInteger code, NSString * _Nonnull message) {
NSLog(@"result:%ld - %@", code, message);
};
[MTMAService start:config];
}
此代码块在浮窗中显示
部分参数说明
- appKey
- 请确保应用内配置的 appkey 与 Portal 上创建应用后生成的 appkey 一致。
- channel
- 指明应用程序包的下载渠道,为方便分渠道统计,具体值由你自行定义,如:App Store。
- apsForProduction
- 用于标识当前应用所使用的 APNs 证书环境。
- 0(默认值)表示采用的是开发证书,1 表示采用生产证书发布应用。
- 注:此字段的值要与 Build Settings的Code Signing 配置的证书环境一致。