You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS 10下Google Sign-in异常重定向至谷歌首页问题排查

Hey there, let's figure out why your Google Sign-in is misbehaving on iOS 10 while working fine on iOS 11, and how to fix it:

Possible Causes & Fixes

1. SFSafariViewController Callback Handling Differences

iOS 10 and iOS 11 have subtle differences in how SFSafariViewController handles callbacks. On iOS 10, the Google Sign-in SDK might fail to properly catch the authorization completion signal, leading it to redirect to Google's homepage instead of your app's follow-up flow.

  • Fix Steps:
    • Make sure you've correctly implemented the application(_:open:options:) method (or application(_:open:sourceApplication:annotation:) for iOS 9 and earlier) and that you're calling GIDSignIn.sharedInstance().handle(url) inside it to process the callback URL.
    • Double-check your Info.plist for the correct URL Scheme, which should be in the format com.googleusercontent.apps.{YOUR_CLIENT_ID}. This must match the client ID you registered in the Google Cloud Console.

2. Google Sign-in SDK Version Compatibility

Newer versions of the Google Sign-in SDK might not have full support for iOS 10, or certain APIs behave differently on iOS 10 compared to iOS 11+.

  • Fix Steps:
    • Try downgrading to an SDK version that explicitly supports iOS 10, like the GoogleSignIn 5.x series (note: 5.x officially supports iOS 9+).
    • If you're using CocoaPods, specify the version in your Podfile:
      pod 'GoogleSignIn', '~> 5.0.2'
      
    • Run pod install to update your dependencies afterward.

3. Redirect URI Configuration Issues

The redirect URI you set up in the Google Cloud Console might not be properly adapted for iOS 10's behavior. iOS 10 has stricter handling for custom URL schemes, or the redirect URI isn't pointing correctly to your app.

  • Fix Steps:
    • Log into the Google Cloud Console, navigate to your project's APIs & Services > Credentials page.
    • Verify that the redirect URI for your iOS client is set to {YOUR_URL_SCHEME}:/oauth2callback (e.g., com.googleusercontent.apps.1234567890:/oauth2callback).
    • Ensure there are no extra spaces or typos, save the changes, and retest.

4. App Transport Security (ATS) Restrictions

While iOS 11 also enforces ATS, iOS 10's rules might be stricter, causing the post-login redirect to get blocked—resulting in a fallback to Google's homepage.

  • Fix Steps:
    • Add ATS exceptions in your Info.plist to allow communication with Google-related domains. Here's the configuration to add:
      <key>NSAppTransportSecurity</key>
      <dict>
          <key>NSExceptionDomains</key>
          <dict>
              <key>google.com</key>
              <dict>
                  <key>NSIncludesSubdomains</key>
                  <true/>
                  <key>NSExceptionAllowsInsecureHTTPLoads</key>
                  <false/>
                  <key>NSExceptionRequiresForwardSecrecy</key>
                  <true/>
              </dict>
              <key>googleapis.com</key>
              <dict>
                  <key>NSIncludesSubdomains</key>
                  <true/>
                  <key>NSExceptionAllowsInsecureHTTPLoads</key>
                  <false/>
                  <key>NSExceptionRequiresForwardSecrecy</key>
                  <true/>
              </dict>
          </dict>
      </dict>
      
    • Note: Avoid disabling ATS entirely—only add exceptions for the domains you need.

内容的提问来源于stack exchange,提问作者bigreddawg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:36:25