跳转至
400-881-9892

文档中心

官方文档,可查阅产品介绍、快速入门、用户指南、开发指南、API参考、SDK参考、帮助等信息。

文档中心 互动课堂

Initialization and registration settings related interfaces

instance
  • Brief Description

Create a singleton object of TKRoomManager, and the object must be created through this interface.

  • Interface Name

+ (instancetype)instance

  • Method Example
1
2
3
4
5
6
7
8
9
@interface RoomController : NSObject@property (strong, nonatomic) TKRoomManager *roomMgr;@end
@implementation RoomController- (instancetype)init {
    self = [super init];
    if (self) {
        _roomMgr = [TKRoomManager instance];
    }
    return self;
}
@end
  • Return Value Description
Type Description
instancetype An instance object of type TKRoomManager

destory

  • Brief Description

Destroy the singleton object of TKRoomManager, and this interface must be called.

  • Interface Name

+ (void)destory

  • Method Example

[TKRoomManager destory];

  • Return Value Description
Type Description
None None

setLogLevel

  • Brief Description

Set the SDK log printing level, and logs will be written to the sandbox.

  • Interface Name

- (int)setLogLevel:(TKLogLevel)level logPath:(NSString * _Nullable)logPath debugToConsole:(BOOL)debug

  • Parameters
Parameter Name Required Type Description
level Yes TKLogLevel Log Level
logPath No NSString The path for logs to be written to the sandbox; the default path is: Library/Caches/TKSDKLogs
debug Yes BOOL Whether the console outputs logs: YES means logs will be printed to the console, NO means logs will not be printed to the console
  • Method Example
1
2
3
4
5
6
7
- (instancetype)init {
    self = [super init];
    if (self) {
        _roomMgr = [TKRoomManager instance];
        [_roomMgr setLogLevel:TKLogLevelInfo logPath:nil debugToConsole:YES];
    }
    return self;}
  • Return Value Description
Type Description
int 0: Indicates that the call was successful. Non-zero: Indicates that the call failed

initWithAppKey

  • Brief Description

Set the AppID, and this interface must be called to initialize the room information. The appKey needs to be passed in, which can be found in the enterprise backend.

  • Interface Name

- (int)initWithAppID:(NSString *)appID optional:(TKRoomConfig *)config

  • Parameters
Parameter Name Required Type Description
appKey Yes NSString Enterprise Key
config No TKRoomConfig Room Extension Information. You can view the relevant settings fields defined in the TKRoomConfig in the TKRoomDefines.h file according to your own needs
  • Method Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
- (instancetype)init {
    self = [super init];
    if (self) {
        _roomMgr = [TKRoomManager instance]; 
        [_roomMgr setLogLevel:TKLogLevelInfo logPath:logPath debugToConsole:YES];

        TKRoomConfig *config = [[TKRoomConfig alloc] init];
        config.tk_use_secure_socket = YES;
        config.tk_host = self.host;
        config.tk_port = config.tk_use_secure_socket ? @"443" : @"80";
        [_roomMgr initWithAppKey:kAppkey optional:config];
    }
    return self;}
  • Return Value Description
Type Description
int 0: Indicates that the call was successful. Non-zero: Indicates that the call failed

registerRoomManagerDelegate

  • Brief Description

Register the TKRoomManagerDelegate delegate to receive room information callbacks.

  • Interface Name

- (int)registerRoomManagerDelegate:(id<TKRoomManagerDelegate> _Nullable)roomDelegate

  • Parameters
Parameter Name Required Type Description
roomDelegate No id The object that implements the TKRoomManagerDelegate delegate
  • Method Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
@interface RoomController : NSObject<TKRoomManagerDelegate>@property (strong, nonatomic) TKRoomManager *roomMgr;@end
@implementation RoomController- (instancetype)init {
    self = [super init];
    if (self) {
        _roomMgr = [TKRoomManager instance]; 
        [_roomMgr setLogLevel:TKLogLevelInfo logPath:logPath debugToConsole:YES];
 
        TKRoomConfig *config = [[TKRoomConfig alloc] init];
        config.tk_use_secure_socket = YES;
        config.tk_host = self.host;
        config.tk_port = config.tk_use_secure_socket ? @"443" : @"80";
        [_roomMgr initWithAppKey:kAppkey optional:config];
        [_roomMgr registerRoomManagerDelegate:self];
    }
    return self;}@end
  • Return Value Description
Type Description
int 0: Indicates that the call was successful. Non-zero: Indicates that the call failed

registerMediaDelegate

  • Brief Description

Set the delegate for TKMediaFrameDelegate to receive callbacks for local and remote audio and video data.

  • Interface Name

- (int)registerMediaDelegate:(id<TKMediaFrameDelegate> _Nullable)mediaDelegate

  • Parameters
Parameter Name Required Type Description
mediaDelegate No id The object that implements the TKMediaFrameDelegate delegate
  • Method Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
@interface RoomController : NSObject<TKRoomManagerDelegateTKMediaFrameDelegate>@property (strong, nonatomic) TKRoomManager *roomMgr;@end
@implementation RoomController- (instancetype)init {
    self = [super init];
    if (self) {
        _roomMgr = [TKRoomManager instance]; 
        [_roomMgr setLogLevel:TKLogLevelInfo logPath:logPath debugToConsole:YES];
 
        TKRoomConfig *config = [[TKRoomConfig alloc] init];
        config.tk_use_secure_socket = YES;
        config.tk_host = self.host;
        config.tk_port = config.tk_use_secure_socket ? @"443" : @"80";
        [_roomMgr initWithAppKey:kAppkey optional:config];
        [_roomMgr registerRoomManagerDelegate:self];
        [_roomMgr registerMediaDelegate:self];
    }
    return self;}
  • Return Value Description
Type Description
int 0: Indicates that the call was successful. Non-zero: Indicates that the call failed

Notes

  • For more return error codes, please refer to the error code descriptions in TKRoomErrorCode