Google登录未返回我的应用 [英] Google Sign-In is not returning to my app

查看:101
本文介绍了Google登录未返回我的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Google登录无法重定向回我的应用程序有疑问.

I have a problem with Google Sign-in not redirecting back to my app.

我已按照以下步骤操作( https://developers.google. com/identity/sign-in/ios/start-integrating ),安装了cocoapods,下载了GoogleService-Info.plist(将其添加到我的所有目标中),添加了URL Types(我的捆绑包标识符,然后是我的将客户ID重定向到我的目标,然后一步一步地进行操作.

I have followed the steps (https://developers.google.com/identity/sign-in/ios/start-integrating), installed cocoapods, downloaded the GoogleService-Info.plist (added it to all of my targets), added the URL Types (my bundle identifier and then my reverse client ID to my target and followed the steps line by line.

这是plist CFBundleURLTypes的源代码:

Here is the source code of the plist CFBundleURLTypes:

    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>MY_REVERSE_CLIENT_ID</string>
        </array>
        <key>CFBundleURLName</key>
        <string>MY_BUNDLE_ID</string>
    </dict>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>MY_BUNDLE_ID</string>
        </array>
        <key>CFBundleURLName</key>
        <string>MY_BUNDLE_ID</string>
    </dict>

在应用程序委托中,我配置了[GGLContext sharedInstance],并在应用程序openURL方法中添加了-

In the App Delegate, I configured the [GGLContext sharedInstance] and in application openURL method I added-

返回[[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication 注解:annotation];

return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation];

如果未安装Google Plus应用,则可以在应用中正常打开safari,一旦登录,委托回调方法将按预期工作.

If the Google Plus app is not installed, then safari opens in app just fine and once signed in, the delegate callback methods work just as expected.

我认为这是iOS9的问题.以前在iOS8上可以使用.

I believe this is an issue with iOS9. This worked before on iOS8.

我还在我的plist的LSApplicationQueriesSchemes中添加了com-google-gidconsent和com-google-gidconsent-google,因为我看到另一条帖子说可能是问题所在.

I have also added com-google-gidconsent and com-google-gidconsent-google to LSApplicationQueriesSchemes in my plist, as I saw another post that said that could be the issue.

我检查了在Google Developer Portal中我的捆绑软件ID是否与我项目的捆绑软件ID相匹配,以及客户端ID和反向客户端ID是否正确.

I have checked that in the google developer portal my bundle ID matches my project's bundle id as well as the client id and reverse client id are correct.

我有三个目标(生产,暂存和测试).我目前只是在尝试实现生产目标.

I have three targets (production, staging and testing). I am currently just trying to get the production target working.

我还有另一个视图控制器,用户在其中单击google按钮,然后对该按钮执行的操作是[[GIDSignIn sharedInstance] signIn];这会将用户带到Google Plus应用,并提示用户选择一个帐户.选择帐户后,Google Plus应用程序会询问用户我的应用程序是否可以访问其信息.用户单击确定"后,将没有回调到我的应用程序.用户只是停留在Google Plus应用中.我在应用程序openURL方法中有一个断点,但它从未被击中.

I have another view controller where a user clicks a google button and then the action for that button is [[GIDSignIn sharedInstance] signIn]; This takes the user to the Google Plus App and prompts the user to select an account. Once an account is selected, the google plus app then asks the user if my app can access their information. Once a user clicks OK, there is no callback to my app. The user is simply stuck in the Google Plus App. I have a breakpoint in the application openURL method and it never gets hit.

很有意思的是,如果我使用反向客户端ID在URL方案中使用com-google-gidconsent-google和com.google.gidconsent配置我的plist,则应用程序openURL方法会被命中,但

Interestingly enough, if I configure my plist with com-google-gidconsent-google and com.google.gidconsent in the URL schemes with my reverse client id, the application openURL method gets hit but the

[[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication 注解:annotation];

[[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation];

评估为否.

任何帮助将不胜感激.

推荐答案

检查您的application:openURL:sourceApplication:annotation:方法或application:openURL:options :(取决于您在AppDelegate中拥有哪一个).应该是针对Google url方案实现的类似内容

Check your application:openURL:sourceApplication:annotation: method, or application:openURL:options: (depends of which one you have in your AppDelegate). Should be something like this implemented for google url scheme

return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation];

这篇关于Google登录未返回我的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆