Cocos Analytics iOS SDK 接入文档

SDK下载

导入 SDK

下载 SDK 后解压后得到如下文件:

将里面的内容拷贝到目标工程:

添加引用库:

SDK 初始化

...
#import "include/cocos-analytics/CAAgent.h"
...
[CAAgent init:@"app_123456"        // 游戏ID
      storeID:@"apple store"       // 应用商店
       engine:@"cocos"             // 游戏引擎 默认“Cocos”
];

请在 AppDelegate 的 didFinishLaunchingWithOptions 处调用初始化接口。

在游戏前后台切换时分别调用 onPause 和 onResume,在结束游戏时调用 onDestroy:

- (void)applicationDidEnterBackground:(UIApplication *)application {
    [CAAgent onPause];
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    [CAAgent onResume];
}

- (void)applicationWillTerminate:(UIApplication *)application {
    [CAAgent onDestroy];
}

本地调试

SDK 还提供了 CAAgent::enableDebug(boolean) 来开启/关闭本地日志的输出。调试成功后,请设置为 False 或者移除此方法。

results matching ""

    No results matching ""