集成指引
最新更新: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 配置的證書環境一致。