菜鸟教程小白 发表于 2022-12-13 09:00:43

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


                                            <p><p>而 <a href="http://quickblox.com/developers/SimpleSample-users-ios#Signing_Up" rel="noreferrer noopener nofollow">signing up a new user</a>在带有登录名和密码凭据的 ios 应用程序的 QuickBlox 中,应用程序崩溃并且 NSLog 控制台显示如下错误,</p>

<blockquote>
<p><strong>Terminating app due to uncaught exception &#39;BaseServiceException&#39;,
reason: &#39;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.</strong> </p>
</blockquote>

<pre><code>First throw call stack:(
0   CoreFoundation                      0x038365e4 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x02ca48b6 objc_exception_throw + 44
2   VideoChat                           0x00028e2f - + 1231
3   VideoChat                           0x00028092 - + 162
4   VideoChat                           0x0001b049 + + 825
5   VideoChat                           0x0000457d - + 2077
6   UIKit                               0x017ff355 - + 309
7   UIKit                               0x017ffb95 - + 1536
8   UIKit                               0x018043a8 - + 824
9   UIKit                               0x0181887c - + 3447
10UIKit                               0x01818de9 - + 85
11UIKit                               0x01806025 _UIApplicationHandleEvent + 736
12GraphicsServices                  0x03d6b2f6 _PurpleEventCallback + 776
13GraphicsServices                  0x03d6ae01 PurpleEventCallback + 46
14CoreFoundation                      0x037b1d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
15CoreFoundation                      0x037b1a9b __CFRunLoopDoSource1 + 523
16CoreFoundation                      0x037dc77c __CFRunLoopRun + 2156
17CoreFoundation                      0x037dbac3 CFRunLoopRunSpecific + 467
18CoreFoundation                      0x037db8db CFRunLoopRunInMode + 123
19UIKit                               0x01803add - + 840
20UIKit                               0x01805d3b UIApplicationMain + 1225
21VideoChat                           0x00004cbd main + 141
22libdyld.dylib                     0x033dc725 start + 0)
</code></pre>

<p>我正在使用下面的代码来创建一个新用户,</p>

<pre><code>[QBRequest createSessionWithSuccessBlock:^(QBResponse *response, QBASession *session) {
    // session created
} errorBlock:^(QBResponse *response) {
    // handle errors
    NSLog(@&#34;%@&#34;, response.error);
}];

QBUUser *user = ;
user.password = @&#34;azhhdsf&#34;;
user.login = @&#34;dsfgsgf&#34;;

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

<p>我看到一个答案 <a href="https://stackoverflow.com/a/20593701/756941" rel="noreferrer noopener nofollow">here on SO</a> ,但它会抛出一个错误,即 <code>delegate:self</code> 已被弃用,需要使用上述方法 <code>signUp: successBlock:</code>。</p>

<p>有人遇到过这个问题吗?如何解决这个问题?任何建议将不胜感激。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>所有这些请求都是异步的,你不能这样使用它。</p>

<p>正确的方法是等到 session 创建完成后再注册一个用户:</p>

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

    QBUUser *user = ;
    user.password = @&#34;azhhdsf&#34;;
    user.login = @&#34;dsfgsgf&#34;;

    // Registration/sign up of User
    [QBRequest signUp:user successBlock:^(QBResponse *response, QBUUser *user) {
      // Sign up was successful
    } errorBlock:^(QBResponse *response) {
      // Handle error here
      NSLog(@&#34;error while signing up with QB&#34;);
    }];
} errorBlock:^(QBResponse *response) {
    // handle errors
    NSLog(@&#34;%@&#34;, response.error);
}];
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 从 ios 应用程序在 QuickBlox 中注册新用户时终止应用程序,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/25723295/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/25723295/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 从 ios 应用程序在 QuickBlox 中注册新用户时终止应用程序