我在github中使用ios sdk中的示例代码并添加了我的帐户详细信息但是当我在chatviewcontroller中发送消息时,我得到了这个日志:
- [QBChat sendMessage:] - >返回。您必须登录才能使用Chat API 我尝试了许多解决方案但没有成功,我的代码创建了一个会话:
-(void)goToProfile{
QBASessionCreationRequest *extendedAuthRequest = [QBASessionCreationRequest request];
extendedAuthRequest.userLogin =email.text;
extendedAuthRequest.userPassword =motDePasse.text;
[QBAuth createSessionWithExtendedRequest:extendedAuthRequest delegate:self ];
}
之后在completedWithResult:(Result *)结果上下文中:(void *)contextInfo:
// QuickBlox API queries delegate
-(void)completedWithResult:(Result *)result context:(void *)contextInfo{
NSLog(@"errors=%@", result.errors);
// QuickBlox User authentication result
if([result isKindOfClass:[QBUUserLogInResult class]]){
// Success result
if(result.success){
QBUUserLogInResult *res = (QBUUserLogInResult *)result;
NSLog(@"------------Logged In user=%@", res);
// Read about Chat password there http://quickblox.com/developers/Chat#Password
//
if([((__bridge NSString *)contextInfo) isEqualToString:socialLoginContext]){
res.user.password = [QBBaseModule sharedModule].token;
}else{
res.user.password = motDePasse.text;
}
// Save current user
//
[[LocalStorageService shared] setCurrentUser: res.user];
// Login to QuickBlox Chat
//
[[ChatService instance] loginWithUser:[LocalStorageService shared].currentUser completionBlock:^{
NSLog(@"------------local sotrage Logged In user=%@", [LocalStorageService shared].currentUser);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You have successfully logged in"
message:nil
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert show];
//
// hide alert after delay
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[alert dismissWithClickedButtonIndex:0 animated:YES];
});
}];
[[UserChoice sharedUserChoice]setIsConnectedUser:1];
MySlideViewController *slideViewController = [[MySlideViewController alloc] initWithNibName:@"SlideViewController" bundle:nil];
slideViewController.myDataUser = resultG;
slideViewController.delegate = slideViewController;
[[UserChoice sharedUserChoice] setMyUserProfile:resultG];
slideViewController.myDataUserIn = [[UserChoice sharedUserChoice]myUserProfile];
slideViewController.paramGeolocalisation = paramGeo;
[self.navigationController pushViewController:slideViewController animated:YES];
self.navigationController.navigationBarHidden = YES;
// Errors
}else{
NSString *errorMessage = [[result.errors description] stringByReplacingOccurrencesOfString:@"(" withString:@""];
errorMessage = [errorMessage stringByReplacingOccurrencesOfString:@")" withString:@""];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Errors"
message:errorMessage
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert show];
}
}
}
答案 0 :(得分:1)
这意味着您尝试发送邮件,但仍未登录。
查看本指南
http://quickblox.com/developers/SimpleSample-chat_users-ios
// login to Chat
[[QBChat instance] loginWithUser:currentUser];
#pragma mark -
#pragma mark QBChatDelegate
// Chat delegate
-(void) chatDidLogin{
// You have successfully signed in to QuickBlox Chat
// Now you can send a message
}
答案 1 :(得分:0)
看起来你应该这样更新你的代码:
// Login to QuickBlox Chat
[[ChatService instance] loginWithUser:[LocalStorageService shared].currentUser completionBlock:^{
NSLog(@"------------local sotrage Logged In user=%@", [LocalStorageService shared].currentUser);
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You have successfully logged in"
message:nil
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[alert show];
//
// hide alert after delay
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[alert dismissWithClickedButtonIndex:0 animated:YES];
});
[[UserChoice sharedUserChoice]setIsConnectedUser:1];
MySlideViewController *slideViewController = [[MySlideViewController alloc] initWithNibName:@"SlideViewController" bundle:nil];
slideViewController.myDataUser = resultG;
slideViewController.delegate = slideViewController;
[[UserChoice sharedUserChoice] setMyUserProfile:resultG];
slideViewController.myDataUserIn = [[UserChoice sharedUserChoice]myUserProfile];
slideViewController.paramGeolocalisation = paramGeo;
[self.navigationController pushViewController:slideViewController animated:YES];
self.navigationController.navigationBarHidden = YES;
}];