Googlelogin不会返回到我的应用程序

我在使用Googlelogin时遇到问题,无法redirect到我的应用。

我已经按照步骤( https://developers.google.com/identity/sign-in/ios/start-integrating ),安装了cocoapods,下载了GoogleService-Info.plist(将其添加到我的所有目标),添加URLtypes(我的捆绑包标识符,然后是我的反向客户端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中,我configuration了[GGLContext sharedInstance],并在应用程序的openURL方法中添加了 –

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

如果没有安装Google Plus应用程序,Safari会在应用程序中打开并且一旦login,委托callback方法将按照预期工作。

我相信这是iOS9的一个问题。 这在iOS8以前工作。

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

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

我有三个目标(生产,分期和testing)。 我目前只是试图让生产目标工作。

我有另一个视图控制器,用户点击一个谷歌button,然后该button的操作是[[GIDSignIn sharedInstance] signIn]; 这使用户访问Google Plus应用程序,并提示用户select一个帐户。 一旦select一个帐户,谷歌加应用程序然后询问用户我的应用程序是否可以访问他们的信息。 一旦用户点击确定,就没有callback到我的应用程序。 用户只是停留在Google Plus应用程序中。 我在应用程序openURL方法中有一个断点,它永远不会被击中。

有趣的是,如果我使用com-google-gidconsent-google和com.google.gidconsent在我的反向客户端id中configuration我的plist,应用程序的openURL方法会被击中,但是

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

评估为NO。

任何帮助将不胜感激。

检查你的应用程序:openURL:sourceApplication:annotation:method或application:openURL:options :(取决于你在AppDelegate中的哪一个)。 应该是这样的谷歌url计划实施

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

我读到你把你的计划放进你的plist中。 但无论如何,我会把XML(plist文件)与必要的url来configuration谷歌加。 第一行应该是你在你的谷歌开发者控制台中用你的客户端ID在“iOS URL Scheme”中find的

 <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>