gpt4 book ai didi

ios - 从 iOS 应用程序在 QuickBlox 中注册新用户时终止应用程序

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:42:24 24 4
gpt4 key购买 nike

同时 signing up a new user在带有登录名和密码凭据的 ios 应用程序的 QuickBlox 中,应用程序崩溃并且 NSLog 控制台显示如下错误,

Terminating app due to uncaught exception 'BaseServiceException', reason: 'You have missed the authorization call. Please insert following code inside your application [QBRequest createSessionWithSuccessBlock:errorBlock:]; Before any other code, that uses our service, but after setup credentials.

First throw call stack:(
0 CoreFoundation 0x038365e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02ca48b6 objc_exception_throw + 44
2 VideoChat 0x00028e2f -[QBHTTPConnection generateRequestOperation:forPath:usingMethod:] + 1231
3 VideoChat 0x00028092 -[QBConnection executeRequest:forPath:usingMethod:] + 162
4 VideoChat 0x0001b049 +[QBRequest(QBAuth) signUp:successBlock:errorBlock:] + 825
5 VideoChat 0x0000457d -[AppDelegate application:didFinishLaunchingWithOptions:] + 2077
6 UIKit 0x017ff355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
7 UIKit 0x017ffb95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
8 UIKit 0x018043a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
9 UIKit 0x0181887c -[UIApplication handleEvent:withNewEvent:] + 3447
10 UIKit 0x01818de9 -[UIApplication sendEvent:] + 85
11 UIKit 0x01806025 _UIApplicationHandleEvent + 736
12 GraphicsServices 0x03d6b2f6 _PurpleEventCallback + 776
13 GraphicsServices 0x03d6ae01 PurpleEventCallback + 46
14 CoreFoundation 0x037b1d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
15 CoreFoundation 0x037b1a9b __CFRunLoopDoSource1 + 523
16 CoreFoundation 0x037dc77c __CFRunLoopRun + 2156
17 CoreFoundation 0x037dbac3 CFRunLoopRunSpecific + 467
18 CoreFoundation 0x037db8db CFRunLoopRunInMode + 123
19 UIKit 0x01803add -[UIApplication _run] + 840
20 UIKit 0x01805d3b UIApplicationMain + 1225
21 VideoChat 0x00004cbd main + 141
22 libdyld.dylib 0x033dc725 start + 0)

我正在使用下面的代码创建一个新用户,

[QBRequest createSessionWithSuccessBlock:^(QBResponse *response, QBASession *session) {
// session created
} errorBlock:^(QBResponse *response) {
// handle errors
NSLog(@"%@", response.error);
}];

QBUUser *user = [QBUUser user];
user.password = @"azhhdsf";
user.login = @"dsfgsgf";

// Registration/sign up of User
[QBRequest signUp:user successBlock:^(QBResponse *response, QBUUser *user) {
// Sign up was successful
} errorBlock:^(QBResponse *response) {
// Handle error here
NSLog(@"error while signing up with QB");
}];

我看到了一个答案here on SO ,但它会抛出一个错误,即 delegate:self 已被弃用,需要使用上述方法 signUp: successBlock:

有人遇到过这个问题吗?如何解决这个问题?任何建议将不胜感激。

最佳答案

所有这些请求都是异步的,你不能这样使用它。

正确的方法是等到 session 创建后再注册用户:

[QBRequest createSessionWithSuccessBlock:^(QBResponse *response, QBASession *session) {
// session created

QBUUser *user = [QBUUser user];
user.password = @"azhhdsf";
user.login = @"dsfgsgf";

// Registration/sign up of User
[QBRequest signUp:user successBlock:^(QBResponse *response, QBUUser *user) {
// Sign up was successful
} errorBlock:^(QBResponse *response) {
// Handle error here
NSLog(@"error while signing up with QB");
}];
} errorBlock:^(QBResponse *response) {
// handle errors
NSLog(@"%@", response.error);
}];

关于ios - 从 iOS 应用程序在 QuickBlox 中注册新用户时终止应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25723295/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com