0
我們的應用程序使用Podfile來包含'QuickBlox',但我無法成功創建新用戶。以下是使用已確定的用戶名和密碼的代碼。我錯過了明顯的東西嗎?我不能使用QBRequest createSessionWithSuccessBlock
方法,因爲它不再在SDK中。嘗試在Objective-C中創建Quickblox用戶返回「已取消」
self.qbUser = [QBUUser user];
self.qbUser.login = self.user.userId;
//
// use salted SHA1 as password
//
self.qbUser.password = self.user.password;
[SVProgressHUD show];
__weak typeof(self) weakSelf = self;
//
// block to start chat
//
void (^chatBlock)(QBUUser *) = ^(QBUUser *user) {
[[QBChat instance] connectWithUser:user completion:^(NSError * _Nullable error) {
NSLog(@"Chat Error: %@", error);
weakSelf.isLoggedInToQb = NO;
}];
};
//
// block for logging in an already-created user
//
void (^loginBlock)(QBUUser *) = ^(QBUUser *startUser) {
[QBRequest logInWithUserLogin:startUser.login password:startUser.password successBlock:^(QBResponse *response, QBUUser *loggedInUser) {
weakSelf.isLoggedInToQb = YES;
chatBlock(startUser);
} errorBlock:^(QBResponse *response) {
// error handling
NSLog(@"error: %@", response.error);
weakSelf.isLoggedInToQb = NO;
}];
};
//
// attempt to create the user
//
self.qbLoginRequest = [QBRequest signUp:self.qbUser successBlock:^(QBResponse * _Nonnull response, QBUUser * _Nullable user) {
[SVProgressHUD dismiss];
// user created, go ahead and log in
loginBlock(user);
} errorBlock:^(QBResponse * _Nonnull response) {
[SVProgressHUD dismiss];
NSLog(@"Unable to create user to log in: %@", response.error.error);
NSLog(@"request was cancelled: %@", weakSelf.qbLoginRequest.canceled ? @"YES" : @"NO");
// I would expect a status like QBUserAlreadyExists, but..
//if(response.status == QBResponseStatusCodeOK) {
// try logging in anyway
loginBlock(weakSelf.qbUser);
//}
}];
我得到的輸出表示請求被取消,即使self.qbLoginRequest.canceled
是假的。以下是上述代碼的控制檯輸出。我懷疑我錯過了一步驗證。該會話最近從QuickBlox中刪除,這將是顯而易見的首要檢查。
2016-05-04 10:12:50.397 charly[99771:16346643] [QBCore] Response error: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://api.dev.quickblox.com/session.json, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=https://api.dev.quickblox.com/session.json}
2016-05-04 10:12:50.397 charly[99771:16346643] [QBCore] Response error reasons: {
error = {
message = cancelled;
};
}
2016-05-04 10:12:50.398 charly[99771:16346643] [QBAuth] Create Session request error: (null)
2016-05-04 10:12:50.401 charly[99771:16346593] [QBCore] Response error: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://api.dev.quickblox.com/session.json, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=https://api.dev.quickblox.com/session.json}
2016-05-04 10:12:50.401 charly[99771:16346342] Unable to create user to log in: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://api.dev.quickblox.com/session.json, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=https://api.dev.quickblox.com/session.json}
2016-05-04 10:12:50.401 charly[99771:16346342] request was cancelled: NO
2016-05-04 10:12:50.401 charly[99771:16346593] [QBCore] Response error reasons: {
error = {
message = cancelled;
};
}
2016-05-04 10:12:50.401 charly[99771:16346593] [QBCore] Request URL:https://api.dev.quickblox.com/session.json
2016-05-04 10:12:50.401 charly[99771:16346593] [QBCore] Request method: POST
2016-05-04 10:12:50.402 charly[99771:16346593] [QBCore] Request parameters:{
"application_id" = 39734;
"auth_key" = c85fDePFNeGUkBh;
nonce = 319;
signature = d13c7681ea38fe7d3c6eff3a5fc1be251810401b;
timestamp = 1462371170;
}
2016-05-04 10:12:50.402 charly[99771:16346593] [QBCore] Request headers: {
"Accept-Language" = "en-US;q=1";
"Content-Type" = "application/x-www-form-urlencoded";
"QB-OS" = "iOS 9.3";
"QB-SDK" = "iOS 2.7.2";
"QuickBlox-REST-API-Version" = "0.1.1";
"User-Agent" = "charly/1.0 (iPhone; iOS 9.3; Scale/3.00)";
}
2016-05-04 10:12:50.470 charly[99771:16346593] [QBCore] Response error: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://api.dev.quickblox.com/session.json, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=https://api.dev.quickblox.com/session.json}
2016-05-04 10:12:50.470 charly[99771:16346593] [QBCore] Response error reasons: {
error = {
message = cancelled;
};
}
2016-05-04 10:12:50.470 charly[99771:16346593] [QBAuth] Create Session request error: (null)
2016-05-04 10:12:50.473 charly[99771:16346342] error:
Error reasons:{
error = {
message = cancelled;
};
}
2016-05-04 10:12:50.473 charly[99771:16346593] [QBCore] Response error: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLKey=https://api.dev.quickblox.com/session.json, NSLocalizedDescription=cancelled, NSErrorFailingURLStringKey=https://api.dev.quickblox.com/session.json}
2016-05-04 10:12:50.473 charly[99771:16346593] [QBCore] Response error reasons: {
error = {
message = cancelled;
};
}
2016-05-04 10:12:50.731 charly[99771:16346593] [QBCore] Answer DNS chat.quickblox.com [connectivity-1]
我曾嘗試添加會話,但導致代碼崩潰。
QBASession *session = [QBASession new];
[[QBSession currentSession] startSessionWithDetails:session];
如果我把創建QBUUser
以上,代碼墜毀在排隊叫號QBRequest signUp
。
請在[github](https://github.com/QuickBlox/quickblox-ios-sdk)上創建問題並附上完整日誌。 啓用完整日誌://啓用Quickblox REST API調用調試控制檯輸出[QBSettings setLogLevel:QBLogLevelDebug]; //在控制檯輸出中啓用詳細的XMPP日誌記錄[QBSettings enableXMPPLogging];您的幫助受到高度讚賞,並有助於我們提高解決問題的能力。 –