You need to enable JavaScript to run this app.
最新活动
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们
导航

iOS

最近更新时间2023.09.27 15:15:22

首次发布时间2022.07.18 21:28:41

本章节为您介绍初始化方法,请参考文档提供的示例进行初始化配置。视频直播 SDK(TTSDK) 只需要初始化一次,推/拉流功能模块可共用。

前提条件

初始化环境

集成 TTSDK 后,在 App 启动时需要对 TTSDK 进行初始化操作,操作示例如下所示。

#import <TTSDK/TTSDKManager.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Your code...
    [self initTTSDK];
    // Your code...
    return YES;
}

- (void)initTTSDK {
    // .....
}

创建 TTSDKConfiguration

- (void)initTTSDK {
    // 使用申请到的 APPID 创建 TTSDKConfiguration
    TTSDKConfiguration *configuration = [TTSDKConfiguration defaultConfigurationWithAppID:@"xxxxxx"];
    // 填入控制台的 App 信息
    configuration.appName = @"AppName";
    configuration.channel = @"local_test";
    configuration.bundleID = @"BundleID";
}

设置 License 路径

- (void)initTTSDK {
    //...
    configuration.licenseFilePath = [NSBundle.mainBundle pathForResource:@"path/to/license" ofType:nil];
    //...
}

初始化 SDK

将 TTSDKConfiguration 传入 TTSDKManager。

- (void)initTTSDK {
    // 使用申请到的 APPID 创建 TTSDKConfiguration
    TTSDKConfiguration *configuration = [TTSDKConfiguration defaultConfigurationWithAppID:@"xxxxxx"];
    // 填入控制台的 App 信息
    configuration.appName = @"AppName";
    configuration.channel = @"local_test";
    configuration.bundleID = @"BundleID";
    configuration.licenseFilePath = [NSBundle.mainBundle pathForResource:@"path/to/license" ofType:nil];
    [TTSDKManager startWithConfiguration:configuration];
}

日志上报

线上问题的排查和质量平台的数据展示都依赖 SDK 上报的日志,因此,日志上报功能默认开启。如有特殊的数据保密要求,您可以通过将 TTSDKConfigurationshouldInitAppLog 配置为 NO 来关闭日志上报。

- (void)initTTSDK {
//....    
configuration.shouldInitAppLog = NO;
//....
}