菜鸟教程小白 发表于 2022-12-12 20:26:48

ios - GIDSignInDelegate 方法不在 iOS 8.4 中调用


                                            <p><p>我已经在我的应用中实现了 <code>google signIn</code>。</p>

<p>它在 <code>iOS 9+</code> 中运行良好。但它在 <code>8+</code> 版本中产生了问题。</p>

<p>我已将 google 登录初始化为:</p>

<pre><code>.uiDelegate = self;
.delegate = self;
</code></pre>

<p>在我的 <code>button</code> 点击下面的代码是他们的:</p>

<pre><code>    - (void)userDidTapSignInButton:(UIButton*)sender {

      [ signIn];

    }
</code></pre>

<p>只有这个 <code>Google Delegate</code> 被调用:</p>

<pre><code>    - (void)signInWillDispatch:(GIDSignIn *)signIn error:(NSError *)error {

      NSLog(@&#34;Show Sign In Screen&#34;);

   }
</code></pre>

<p>在此 <code>Google Sign</code> 页面打开后。当我按下确认和完成时输入我的用户登录详细信息后,我将被重定向回我的应用程序。在这之后什么也没有发生。 </p>

<p>没有调用成功和失败的委托(delegate)。</p>

<pre><code>- (void)signIn:(GIDSignIn *)signIn
          didSignInForUser:(GIDGoogleUser *)user
withError:(NSError *)error {
       NSLog(@&#34;Google Sign IN SUccess&#34;);
   }
</code></pre>

<p>失败代表:</p>

<pre><code>- (void)signIn:(GIDSignIn *)signIn
   didDisconnectWithUser:(GIDGoogleUser *)user
withError:(NSError *)error {
    NSLog(@&#34;google sign in fail with error&#34;);
   }
</code></pre>

<p>当我在 iOS 9.2 或 9.3 中运行我的应用程序时,它运行良好,每个委托(delegate)都被调用。但在 iOS 8.4、8.3 中没有,...</p>

<p>我无法找出背后的原因。</p>

<p>我也没有在控制台中收到任何日志或错误消息。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>你要实现ios 9.0版本和ios 8.0版本的open url功能。</p>

<pre><code>   @available(iOS 8.0,*)
func application(application: UIApplication,
               openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -&gt; Bool {
    print(&#34;sign in with annotation&#34;)
    return GIDSignIn.sharedInstance().handleURL(url,
                                                sourceApplication: sourceApplication,
                                                annotation: annotation)
}
@available(iOS 9.0, *)
func application(app: UIApplication, openURL url: NSURL, options: ) -&gt; Bool {
    print(&#34;sign in with options&#34;)
    return GIDSignIn.sharedInstance().handleURL(url,
                                                sourceApplication: options as! String?,
                                                annotation: options)
}
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - GIDSignInDelegate 方法不在 iOS 8.4 中调用,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/37697908/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/37697908/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - GIDSignInDelegate 方法不在 iOS 8.4 中调用