我在我的应用程序中使用Quickblox进行视频通话,我注册并成功登录但是当我尝试使用以下行创建QBRTCSession时,我总是得到一个nill,请帮助我。
QBRTCSession* videoSession = [QBRTCClient.instance createNewSessionWithOpponents:opponentsIDs withConferenceType:QBRTCConferenceTypeVideo];
以下是我的总代码:
[QBRequest logInWithUserEmail:[userDefaults valueForKey:@"loginEmail"] password:[userDefaults valueForKey:@"loginPassword"] successBlock:^(QBResponse * _Nonnull response, QBUUser * _Nullable user) {
NSError* error;
QBUUser* theUser = [QBUUser user];
theUser.ID = 00000;
[QBChat.instance connectWithUser:theUser completion:^(NSError * _Nullable error) {
}];
[userDefaults setInteger:user.ID forKey:@"userId"];
[userDefaults synchronize];
[QBRTCClient initializeRTC];
[QBRTCConfig setAnswerTimeInterval:60];
[QBRTCConfig setDialingTimeInterval:10];
[QBRTCConfig setDisconnectTimeInterval:30];// [QBRTCConfig setDTLSEnabled:false];
[[QBRTCMediaStreamConfiguration alloc] init];
configurations.audioCodec = QBRTCAudioCodeciLBC;
configurations.videoCodec = QBRTCVideoCodecH264;
[QBRTCConfig setICEServers:[self quickbloxICE]];
[QBRTCConfig setMediaStreamConfiguration:configurations];
[QBRTCConfig setStatsReportTimeInterval:1.f];
[QBRTCClient.instance addDelegate:self];
NSArray* opponentsIDs = @[@000000];
[QBSettings setAutoReconnectEnabled:YES];
QBRTCSession* videoSession = [QBRTCClient.instance createNewSessionWithOpponents:opponentsIDs withConferenceType:QBRTCConferenceTypeVideo];
CallViewController *callViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"CallViewController"];
callViewController.session = videoSession;
callViewController.initiator = user;
[self presentViewController:callViewController animated:NO completion:nil];
} errorBlock:^(QBResponse * _Nonnull response) {
NSLog(@"%@",[response.error description]);
}];
- (NSArray *)quickbloxICE {
NSString *password = @"baccb97ba2d92d71e26eb9886da5f1e0";
NSString *userName = @"quickblox";
QBRTCICEServer *server = [QBRTCICEServer serverWithURL:@"https://myserver:port" username:@"" password:@""];
QBRTCICEServer * stunServer = [QBRTCICEServer serverWithURL:@"stun:turn.quickblox.com"
username:@""
password:@""];
QBRTCICEServer * turnUDPServer = [QBRTCICEServer serverWithURL:@"turn:turn.quickblox.com:3478?transport=udp"
username:userName
password:password];
QBRTCICEServer * turnTCPServer = [QBRTCICEServer serverWithURL:@"turn:turn.quickblox.com:3478?transport=tcp"
username:userName
password:password];
return@[server,stunServer, turnTCPServer, turnUDPServer];}
答案 0 :(得分:1)
请在连接聊天后创建新的 QBRTCSession 实例:
[QBChat.instance connectWithUser:theUser completion:^(NSError * _Nullable error) {
QBRTCSession* videoSession = [QBRTCClient.instance createNewSessionWithOpponents:opponentsIDs withConferenceType:QBRTCConferenceTypeVideo];
}];