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:
On 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];
}
Session created
#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];
}
}
Logged in to chat
(void) chatDidLogin {
// You have successfully signed in to QuickBlox Chat
[NSTimer scheduledTimerWithTimeInterval:30 target:[QBChat instance] selector:#selector(sendPresence) userInfo:nil repeats:YES];
}
Making the call:
- (IBAction)callUser:(id)sender {
[QBChat instance].delegate = self;
[self.videoChat callUser:USERID conferenceType:QBVideoChatConferenceTypeAudioAndVideo];
}
Getting the call
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;
}
Related
Quickblox webrtc video call receive method is not called .I am call to someone he accept the call and we can communicate but while he is calling me i am not geting that call.
`
- (void)didReceiveNewSession:(QBRTCSession *)session userInfo:(NSDictionary *)userInfo {
if (self.session ) {
[session rejectCall:#{#"reject" : #"busy"}];
return;
}
self.session = session;
[QBRTCSoundRouter.instance initialize];
NSParameterAssert(!self.nav);
IncomingCallViewController *incomingViewController =
[self.storyboard instantiateViewControllerWithIdentifier:#"IncomingCallViewController"];
incomingViewController.delegate = self;
incomingViewController.session = session;
incomingViewController.usersDatasource = self.dataSource;
self.nav = [[UINavigationController alloc] initWithRootViewController:incomingViewController];
[self presentViewController:self.nav animated:NO completion:nil];
}
The Quickblox webrtc video call receive method only called when the user is online so make sure you add in Your -
(Void)ViewDidLoad{
[QBRequest logInWithUserLogin:#"xxxxxx"
password:#"xxxxx"
successBlock:^(QBResponse * _Nonnull response, QBUUser * _Nullable user)
{
}];
[[QBChat instance] connectWithUser:self.user completion:^(NSError * _Nullable error) {
NSLog(#"User%#",self.user);
}];
}
It will be called.
I am using the following code to block group user but it gives me error.
Following is my logic of maintaining QBPrivacyList to block it but I didn't got succeed with it.
-(void)ViewDidLoad{
[[QBChat instance] addDelegate:self];
[[QBChat instance] retrievePrivacyListWithName:#"group_public"];
}
- (void)chatDidReceivePrivacyList:(QBPrivacyList *)privacyList{
[SVProgressHUD dismiss];
blockPrivacyList = privacyList;
[[QBChat instance] setActivePrivacyListWithName:blockPrivacyList.name];
}
-(IBAction)blockGroupUser{
QBPrivacyItem *item = [[QBPrivacyItem alloc] initWithType:GROUP valueForType:user.ID action:DENY];
if (blockPrivacyList) {
[blockPrivacyList addObject:item]; // add new user if already privacy list is there
}else
blockPrivacyList= [[QBPrivacyList alloc] initWithName:#"group_public" items:#[item]];
}
[[QBChat instance] setPrivacyList:blockPrivacyList];
}
Got following Error:
<iq xmlns="jabber:client" id="9C79DCE1-AC59-4C9D-8AB2-BE2387B1EED4" to="5554981-24659#chat.quickblox.com/D060E713-F1DC-46D7-A2BF-8DA7BDB22CBA" type="error"><query xmlns="jabber:iq:privacy"><list name="group_public"><item action="deny" order="5291124" value="5291124-24659#chat.quickblox.com" type="group"><iq/><message/><presence-in/><presence-out/></item></list></query><error type="cancel" code="404"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
Try to activate your privacy list after editing it
http://quickblox.com/developers/SimpleSample-chat_users-ios#Activate_a_privacy_list
-(IBAction)blockGroupUser{
QBPrivacyItem *item = [[QBPrivacyItem alloc] initWithType:GROUP valueForType:user.ID action:DENY];
if (blockPrivacyList) {
[blockPrivacyList addObject:item]; // add new user if already privacy list is there
}else
blockPrivacyList= [[QBPrivacyList alloc] initWithName:#"group_public" items:#[item]];
}
[[QBChat instance] setPrivacyList:blockPrivacyList];
}
- (void)chatDidSetPrivacyListWithName:(NSString *)name{
[[QBChat instance] setDefaultPrivacyListWithName:#"public"];
[[QBChat instance] setActivePrivacyListWithName:#"public"];
}
- (void)chatDidSetDefaultPrivacyListWithName:(NSString *)name{
}
- (void)chatDidNotSetDefaultPrivacyListWithName:(NSString *)name error:(id)error{
}
- (void)chatDidSetActivePrivacyListWithName:(NSString *)name{
}
- (void)chatDidNotSetActivePrivacyListWithName:(NSString *)name error: (id)error{
}
FBSDKGameRequestContent *content = [[FBSDKGameRequestContent alloc]init];
content.message = #"Great FB";
content.title = #"Invite Friends";
FBSDKGameRequestDialog *gameDialog = [[FBSDKGameRequestDialog alloc]init];
gameDialog.content = content;
gameDialog.frictionlessRequestsEnabled = YES;
gameDialog.delegate = self;
if ([gameDialog canShow]) {
[gameDialog show];
}
I am using the above code for showing FBFriends. The dialog is opened, but I want to perform some of my custom functionality after user hits send/cancel.
How should I do it?
You're doing:
gameDialog.delegate = self;
So, why don't you use the delegate methods (FBSDKGameRequestDialogDelegate): gameRequestDialogDidCancel: and
gameRequestDialog:didCompleteWithResults: to know if user has cancelled of sent its invitation?
Source
In your YourCurrentClass.h:
#interface YourCurrentClass : NSObject < FBSDKGameRequestDialogDelegate >
In your YourCurrentClass.m:
- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog
didCompleteWithResults:(NSDictionary *)results
{
//User has done something.
//Check "results" and do something.
}
- (void)gameRequestDialogDidCancel:(FBSDKGameRequestDialog *)gameRequestDialog
{
//User has cancelled
//Do somathing
}
- (void)gameRequestDialog:(FBSDKGameRequestDialog *)gameRequestDialog
didFailWithError:(NSError *)error
{
//An error happened
NSLog(#"Error: %#", error);
//Do something
}
Hi I am using quickblox SDK in my ios app for video chat -
I tried to write QBChat Delegates in my Appdelegate.m - to determine from any view when a QuickBlox call has came
This is my code -
LoginViewController.m
-(IBAction)loginBtn:(id)sender{
[QBUsers logInWithUserLogin:username.text password:password.text delegate:self];
}
-(void)completedWithResult:(Result *)result{
if([result isKindOfClass:[QBUUserLogInResult class]]){
if(result.success){
QBUUserLogInResult *res = (QBUUserLogInResult *)result;
appDelegate.currentUser = res.user;
NSLog(#"QBid-----%d",res.user.ID); // I am getting ID here
[appDelegate QBLogin:self];
}
else
//Errors
}
}
AppDelegate.m
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[QBSettings setApplicationID:13504];
[QBSettings setAuthorizationKey:#"vfte-wg7D2VB4Q"];
[QBSettings setAuthorizationSecret:#"uhytrhqBzFz8eKJ2p"];
[QBSettings setAccountKey:#"b7zksdft56de5q4xX7"];
[QBAuth createSessionWithDelegate:self];
}
-(void)QBLogin:(id)sender{
// Create session with user
QBASessionCreationRequest *extendedAuthRequest = [QBASessionCreationRequest request];
extendedAuthRequest.userLogin = #"mysavedusername";
extendedAuthRequest.userPassword = #"mysavedpassword";
[QBAuth createSessionWithExtendedRequest:extendedAuthRequest delegate:self];
[QBChat instance].delegate = self;
[NSTimer scheduledTimerWithTimeInterval:30 target:[QBChat instance] selector:#selector(sendPresence) userInfo:nil repeats:YES];
}
-(void)completedWithResult:(Result *)result{
if(result.success && [result isKindOfClass:QBAAuthSessionCreationResult.class]){
QBAAuthSessionCreationResult *res = (QBAAuthSessionCreationResult *)result;
QBUUser *currentUser2 = [QBUUser user];
currentUser2.ID = res.session.userID;
currentUser2.password = #"mysavedpassword";
[QBChat instance].delegate = self;
[[QBChat instance] loginWithUser:currentUser];
}
else
// Error
}
-(void) chatDidLogin{
}
-(void) chatDidReceiveCallRequestFromUser:(NSUInteger)userID withSessionID:(NSString *)_sessionID conferenceType:(enum QBVideoChatConferenceType)conferenceType{
videoChatOpponentID = userID;
videoChatConferenceType = conferenceType;
sessionID = _sessionID;
self.videoChat = [[QBChat instance] createAndRegisterVideoChatInstanceWithSessionID:sessionID];
if (self.callAlert == nil) {
//#"person is calling. Would you like to answer?"];
}
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:#selector(hideCallAlert) object:nil];
[self performSelector:#selector(hideCallAlert) withObject:nil afterDelay:4];
}
-(void) chatCallUserDidNotAnswer:(NSUInteger)userID{
//#"User isn't answering. Please try again
}
-(void) chatCallDidRejectByUser:(NSUInteger)userID{
//#"User has rejected your call
}
-(void) chatCallDidAcceptByUser:(NSUInteger)userID{
}
-(void) chatCallDidStopByUser:(NSUInteger)userID status:(NSString *)status{
}
Here I am getting this error message after successful login
-[QBChat loginWithUser:] -> Connecting to Chat, hostName: muc.chat.quickblox.com
-[QBChat loginWithUser:] -> Chat server endpoint: muc.chat.quickblox.com, User JID: 1480900-13504#chat.quickblox.com/1280B391-492D-4C6E-9C72-F832D0D7D78F
QBChat/didConnect
QBChat/didNotAuthenticate, error: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/><text lang="en">Password not verified</text></failure>
-[QBContactList dealloc] ->
QBChat/didDisconnect, error: (null)
-[QBChat sendPresence] -> return. You have to be logged in in order to use Chat API
Where is the mistake ?
Please help me to fix this.
You can write all quickblox delegate methods in appdelegate it self and when call came you can inititate video calling on some other view.
I am using GMTOAuth2 in an application with one viewController and it works fine, Then I add same code to another application that contains more viewControllers, It loads the webView with textfields for username and password but if I click on anything in this view it crashes with Thread 1: EXC_BAD_ACCESS (code=2, address=0xbf7ffffc) with void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode in the console. My code for authorization part looks like this:
- (void)awakeFromNib {
[super awakeFromNib];
GTMOAuth2Authentication *auth = nil;
auth = [GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kKeychainItemName
clientID:kMyClientID
clientSecret:kMyClientSecret];
if (auth)
{
[auth authorizeRequest:nil
delegate:self
didFinishSelector:#selector(authentication:request:finishedWithError:)];
}
}
- (void)signInToGoogle {
[self signOut];
NSString *keychainItemName = kKeychainItemName;
NSString *scope = #"https://spreadsheets.google.com/feeds https://docs.google.com/feeds";
NSString *clientID = kMyClientID;
NSString *clientSecret = kMyClientSecret;
if ([clientID length] == 0 || [clientSecret length] == 0) {
NSString *msg = #"The sample code requires a valid client ID and client secret to sign in.";
[self displayAlertWithMessage:msg];
return;
}
SEL finishedSel = #selector(viewController:finishedWithAuth:error:);
GTMOAuth2ViewControllerTouch *viewController = [[GTMOAuth2ViewControllerTouch alloc] initWithScope:scope
clientID:clientID
clientSecret:clientSecret
keychainItemName:keychainItemName
finishedSelector:finishedSel];
delegate:self
[self presentViewController:viewController animated:YES completion:^{}];
[[self navigationController] pushViewController:viewController animated:YES];
}
- (void)authentication:(GTMOAuth2Authentication *)auth
request:(NSMutableURLRequest *)request
finishedWithError:(NSError *)error {
if (error != nil) {
NSLog(#"error!");
} else {
[self isAuthorizedWithAuthentication:auth];
self.auth = auth;
}
}
And copied the same class from first application to second one, and made exactly same nib file.