首页 文章

Google登录不会返回我的应用

提问于
浏览
4

我在使用Google登录时遇到问题,而不是重定向回我的应用 .

我按照步骤(https://developers.google.com/identity/sign-in/ios/start-integrating),安装了cocoapods,下载了GoogleService-Info.plist(将其添加到我的所有目标中),添加了URL类型(我的包标识符,然后我的反向客户端ID到我的目标并按照步骤操作)逐行 .

以下是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>

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

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

如果没有安装Google Plus应用,那么safari会在app中打开,只需登录,代理回调方法就可以正常工作了 .

我相信这是iOS9的一个问题 . 这在iOS8上有效 .

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

我已经检查过,在Google开发人员门户网站中,我的捆绑包ID与我的项目的捆绑ID相匹配,以及客户端ID和反向客户端ID是否正确 .

我有三个目标( 生产环境 ,分期和测试) . 我目前只是想让 生产环境 目标工作 .

我有另一个视图控制器,用户点击谷歌按钮,然后该按钮的动作是[[GIDSignIn sharedInstance] signIn];这会将用户带到Google Plus应用程序并提示用户选择一个帐户 . 选择帐户后,Google Plus应用程序会询问用户我的应用是否可以访问其信息 . 用户点击“确定”后,我的应用就无法回调 . 用户只是卡在Google Plus应用中 . 我在应用程序openURL方法中有一个断点,它永远不会被击中 .

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

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

评估为NO .

任何帮助将不胜感激 .

2 回答

  • 3

    检查你的应用程序:openURL:sourceApplication:annotation:method或application:openURL:options :(取决于你在AppDelegate中拥有的那个) . 应该像谷歌网址方案这样实现

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

    我读到你把你的计划放进了你的计划 . 但无论如何我会把xml(plist文件)与配置google plus所需的url放在一起 . 第一行应该是您在Google iOS开发者控制台中使用您的客户端ID在“iOS URL Scheme”中找到的内容

    <key>LSApplicationQueriesSchemes</key>
    <array>
    <string>com.googleusercontent.apps.123456789012-abcdefghijklmnopqrstuvwxyz</string>
    <string>com-google-gidconsent-google</string>
    <string>com-google-gidconsent-youtube</string>
    <string>com-google-gidconsent</string>
    <string>com.google.gppconsent.2.4.1</string>
    <string>com.google.gppconsent.2.4.0</string>
    <string>googlechrome</string>
    <string>googlechrome-x-callback</string>
    <string> https://www.googleapis.com/auth/plus.login</string>
    </array>
    

相关问题