iOS MA SDK 集成指南(5.5.0 以前)
适用版本
本文适用于 v5.0.0 及以后、v5.5.0 以前版本的 MTMA SDK。目前 SDK 只支持 iOS 10 以上版本的手机系统。
v5.5.0 及以后版本请查看 集成指南。
如需使用 EngageLab SDK 的 MA 功能,需要同时集成 AppPush 模块。请先在 AppPush 平台创建一个应用获得 AppKey。
配置工程
配置 AppPush
在 MA 控制台配置移动端数据来源时,请选择同时使用 AppPush,并选择实际接入的 AppPush 应用。初始化 AppPush 时使用所选应用的 AppKey。
导入 SDK
Cocoapods 导入
- 请指定 5.5.0 以前的版本(以下以 5.0.0 版本为例):
pod 'MTPush', '5.0.0'
pod 'MTMA', '5.0.0'
pod 'MTPush', '5.0.0'
pod 'MTMA', '5.0.0'
此代码块在浮窗中显示
手动导入
- 将对应旧版本的 SDK 包解压,按 AppPush 集成指南完成 AppPush 导入后,在 Xcode 中选择 “Add files to 'Your project name'...”,将同一 SDK 包中的 MTMA-ios-x.x.x.xcframework 添加到你的工程目录中。
初始化 SDK
在 MTPush 初始化函数调用之后进行 MTMA SDK 的初始化。旧版 MTMA 使用 AppPush 的 AppKey,不需要单独设置 MA AppKey。
请将以下头文件添加到 AppDelegate.m:
#import "MTPushService.h"
#import "MTMAService.h"
#import "MTPushService.h"
#import "MTMAService.h"
此代码块在浮窗中显示
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 先初始化 Push SDK
NSString *appKey = @"your AppPush AppKey";
NSString *channel = @"App Store";
BOOL isProduction = NO;
[MTPushService setupWithOption:launchOptions
appKey:appKey
channel:channel
apsForProduction:isProduction
advertisingIdentifier:nil];
// 再初始化 MTMA SDK
MTMAConfig *config = [[MTMAConfig alloc] init];
config.completion = ^(NSInteger code, NSString *message) {
NSLog(@"result:%ld - %@", (long)code, message);
};
[MTMAService start:config];
return YES;
}
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 先初始化 Push SDK
NSString *appKey = @"your AppPush AppKey";
NSString *channel = @"App Store";
BOOL isProduction = NO;
[MTPushService setupWithOption:launchOptions
appKey:appKey
channel:channel
apsForProduction:isProduction
advertisingIdentifier:nil];
// 再初始化 MTMA SDK
MTMAConfig *config = [[MTMAConfig alloc] init];
config.completion = ^(NSInteger code, NSString *message) {
NSLog(@"result:%ld - %@", (long)code, message);
};
[MTMAService start:config];
return YES;
}
此代码块在浮窗中显示
部分参数说明
- appKey
- 请确保应用内配置的 appKey 与 AppPush 平台上创建应用后生成的 AppKey 一致。
- channel
- 指明应用程序包的下载渠道,为方便分渠道统计,具体值由你自行定义,如:App Store。
- apsForProduction
- 用于标识当前应用所使用的 APNs 证书环境。
- 0(默认值)表示采用的是开发证书,1 表示采用生产证书发布应用。
- 注:此字段的值要与 Build Settings 的 Code Signing 配置的证书环境一致。
- completion
- 初始化结果回调,code 为 0 时表示初始化成功。










