I'm using QuickBlox to make a video call from one device to the other. This is my code on the device making the call:
viewDidLoad
:- (void)viewDidLoad {
[super viewDidLoad];
self.videoChat = [[QBChat instance] createAndRegisterVideoChatInstance];
self.videoChat.viewToRenderOpponentVideoStream = self.otherUserView;
self.videoChat.viewToRenderOwnVideoStream = self.selfView;
QBASessionCreationRequest *extendedAuthRequest = [QBASessionCreationRequest request];
extendedAuthRequest.userLogin = USERNAME
extendedAuthRequest.userPassword = PASSWORD
[QBAuth createSessionWithExtendedRequest:extendedAuthRequest delegate:self];
}
#pragma mark - QBActionStatusDelegate
- (void)completedWithResult:(Result *)result{
if(result.success && [result isKindOfClass:QBAAuthSessionCreationResult.class]){
// Success, You have got User session
QBAAuthSessionCreationResult *res = (QBAAuthSessionCreationResult *)result;
QBUUser *currentUser = [QBUUser user];
currentUser.ID = res.session.userID;
currentUser.password = PASSWORD
// set Chat delegate
[QBChat instance].delegate = self;
// login to Chat
[[QBChat instance] loginWithUser:currentUser];
}
}
(void) chatDidLogin {
// You have successfully signed in to QuickBlox Chat
[NSTimer scheduledTimerWithTimeInterval:30 target:[QBChat instance] selector:@selector(sendPresence) userInfo:nil repeats:YES];
}
- (IBAction)callUser:(id)sender {
[QBChat instance].delegate = self;
[self.videoChat callUser:USERID conferenceType:QBVideoChatConferenceTypeAudioAndVideo];
}
I've checked. The user is logged into the chat, the ID I'm trying to call is correct and the other user is also logged into the chat, but this never gets called:
-(void) chatDidReceiveCallRequestFromUser:(NSUInteger)userID withSessionID:(NSString *)_sessionID conferenceType:(enum QBVideoChatConferenceType)conferenceType {
self.videoChat = [[QBChat instance] createAndRegisterVideoChatInstanceWithSessionID:_sessionID];
//
[self.videoChat acceptCallWithOpponentID:userID conferenceType:conferenceType];
}
So Here is the answer, I was creating the QBVideoChat
object too early. I ended up creating it after I'm logged into the chat
-(void) chatDidLogin {
// You have successfully signed in to QuickBlox Chat
[NSTimer scheduledTimerWithTimeInterval:30 target:[QBChat instance] selector:@selector(sendPresence) userInfo:nil repeats:YES];
self.videoChat = [[QBChat instance] createAndRegisterVideoChatInstance];
self.videoChat.viewToRenderOpponentVideoStream = self.otherUserView;
self.videoChat.viewToRenderOwnVideoStream = self.selfView;
}