重要提示:自
2024 年 5 月 1 日起,对于使用常用 SDK(包括 GoogleSignIn-iOS)的 iOS 应用,Apple
要求提供隐私权清单和签名。请在 2024 年 5 月 1 日之前升级到 GoogleSignIn-iOS v7.1.0 及更高版本。按照
我们的升级指南操作。
Google 登录快速迁移指南
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页详细介绍了 Google 登录 SDK 的主要版本的主要变更。
请按照本指南将您的应用迁移到最新版本的 Google 登录 SDK。请注意,本文档中始终会提及最新版本。
如需了解详情,另请参阅版本说明和 GitHub 上的代码库。
Google 登录 SDK v7.0.0 及更高版本
如需从某个 v7.0.0 之前的 Google 登录 SDK 版本迁移您的应用,请进行以下更改:
在应用的 Info.plist
文件中设置 OAuth 客户端配置。
您可以继续在运行时使用 GIDConfiguration
对象进行设置,但我们不再建议这样做。如需查看示例及更多详情,请参阅使用入门指南。
addScopes:
方法已移至 GIDGoogleUser。现在,您应该在身份验证完成后向 GIDGoogleUser 请求这些范围,而不是向 GIDSignIn 请求额外的授权范围。
如果您要设置 serverClientID
以为您的应用启用服务器端 API 访问权限,完成操作后,系统现在会返回 serverAuthCode
及 GIDSignInResult
。
GIDAuthentication
中的属性已移至 GIDGoogleUser
。
更新方法调用:
v6.2.x |
7.0.0 版及更高版本 |
GIDSignIn
signInWithConfiguration:presentingViewController:callback:
|
GIDSignIn
signInWithPresentingViewController:completion:
|
GIDSignIn
restorePreviousSignInWithCallback:
|
GIDSignIn
restorePreviousSignInWithCompletion:
|
GIDSignIn
disconnectWithCallback:
|
GIDSignIn
disconnectWithCompletion:
|
GIDAuthentication
doWithFreshTokens:
|
GIDGoogleUser
refreshTokensIfNeededWithCompletion:
|
GIDSignIn
addScopes:presentingViewController:callback:
|
GIDGoogleUser
addScopes:presentingViewController:completion:
|
Google 登录 SDK 6.0.0 版
如需从某个 v6.0.0 之前的 Google 登录 SDK 版本迁移您的应用,请进行以下更改:
更新对 GIDSignIn.sharedInstance
属性访问权限的所有 [GIDSignIn sharedInstance]
调用。
将所有客户端配置(客户端 ID 等)移至 GIDConfiguration
对象。
将对已移除方法的调用更新为新的等效方法:
v5.x.x |
v6.0.0 |
signIn |
signInWithConfiguration:presentingViewController:callback: |
restorePreviousSignIn |
restorePreviousSignInWithCallback: |
disconnect |
disconnectWithCallback: |
getTokensWithHandler: |
doWithFreshTokens: |
refreshTokensWithHandler: |
doWithFreshTokens: |
移除对 GIDSignInDelegate
协议及其方法的所有引用。
手动将 GIDSignInButton
连接到使用 IBAction
或类似方法调用 signInWithConfiguration:presentingViewController:callback:
的方法。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eThis page provides migration guides for updating your app to the latest Google Sign-In SDK versions (v7.0.0+ and v6.0.0).\u003c/p\u003e\n"],["\u003cp\u003eFor v7.0.0+, OAuth client configuration should be set in \u003ccode\u003eInfo.plist\u003c/code\u003e, additional scopes are requested from \u003ccode\u003eGIDGoogleUser\u003c/code\u003e, and various properties and methods have been moved or updated.\u003c/p\u003e\n"],["\u003cp\u003eMigrating to v6.0.0 involves using \u003ccode\u003eGIDConfiguration\u003c/code\u003e for client configuration, updating method calls, and replacing \u003ccode\u003eGIDSignInDelegate\u003c/code\u003e with callback blocks.\u003c/p\u003e\n"],["\u003cp\u003eDetailed information and examples are available in linked resources like release notes, GitHub repository, and the "Get Started" guide.\u003c/p\u003e\n"]]],[],null,["This page details key changes for major versions of the Google Sign-In SDK.\n\nFollow this guide to migrate your app to the latest version of the Google\nSign-In SDK. Note that the documentation always refers to the most recent\nversion.\n\nAlso refer to the [release notes](/identity/sign-in/ios/release) and the\n[repository on GitHub](https://github.com/google/GoogleSignIn-iOS)\nfor more information.\n\nGoogle Sign-In SDK v7.0.0+\n\nTo migrate your app from a version of the Google Sign-In SDK prior to v7.0.0,\nmake the following changes:\n\n- Set your OAuth client configuration in your application's `Info.plist` file.\n You can continue to set it at runtime (using a `GIDConfiguration`) object,\n but this is no longer recommended. See the [get\n started](/identity/sign-in/ios/start-integrating#configure_app_project) guide for\n examples and more details.\n\n | `Info.plist` key | Description |\n |---------------------|-------------------------------------------------------------------------------------------------------------------|\n | `GIDClientID` | [OAuth client ID](/identity/sign-in/ios/start-integrating#add_client_id) |\n | `GIDServerClientID` | [Server OAuth client ID for backend authentication](/identity/sign-in/ios/start-integrating#add_server_client_id) |\n | `GIDHostedDomain` | [Google Workspace domain](/identity/sign-in/ios/start-integrating#add_domain_realm) |\n | `GIDOpenIDRealm` | [OpenID realm](/identity/sign-in/ios/start-integrating#add_domain_realm) |\n\n- The `addScopes:` method has been moved to GIDGoogleUser. Instead of\n requesting additional authorization scopes from GIDSignIn, you should now\n [request them from GIDGoogleUser after authentication](/identity/sign-in/ios/api-access#2_request_additional_scopes)\n has completed.\n\n- If you are setting `serverClientID` to [enable server-side API access for\n your app](/identity/sign-in/ios/offline-access), `serverAuthCode` will now be\n returned with `GIDSignInResult` in your completion.\n\n- Properties from `GIDAuthentication` have moved into `GIDGoogleUser`.\n\n- Update method calls:\n\n| v6.2.x | v7.0.0+ |\n|--------------------------------------------------------------------------|------------------------------------------------------------------|\n| `GIDSignIn` `signInWithConfiguration:presentingViewController:callback:` | `GIDSignIn` `signInWithPresentingViewController:completion:` |\n| `GIDSignIn` `restorePreviousSignInWithCallback:` | `GIDSignIn` `restorePreviousSignInWithCompletion:` |\n| `GIDSignIn` `disconnectWithCallback:` | `GIDSignIn` `disconnectWithCompletion:` |\n| `GIDAuthentication` `doWithFreshTokens:` | `GIDGoogleUser` `refreshTokensIfNeededWithCompletion:` |\n| `GIDSignIn` `addScopes:presentingViewController:callback:` | `GIDGoogleUser` `addScopes:presentingViewController:completion:` |\n\nGoogle Sign-In SDK v6.0.0\n\nTo migrate your app from a version of the Google Sign-In SDK prior to v6.0.0,\nmake the following changes:\n\n- Update all `[GIDSignIn sharedInstance]` calls to `GIDSignIn.sharedInstance`\n property accesses.\n\n- Move all client configuration (client IDs, etc.) to a `GIDConfiguration`\n object.\n\n- Update calls to removed methods to their new equivalents:\n\n | v5.x.x | v6.0.0 |\n |-----------------------------|--------------------------------------------------------------|\n | `signIn` | `signInWithConfiguration:presentingViewController:callback:` |\n | `restorePreviousSignIn` | `restorePreviousSignInWithCallback:` |\n | `disconnect` | `disconnectWithCallback:` |\n | `getTokensWithHandler:` | `doWithFreshTokens:` |\n | `refreshTokensWithHandler:` | `doWithFreshTokens:` |\n\n- Remove all references to the `GIDSignInDelegate` protocol and its methods.\n\n - Move the logic from `signIn:didSignInForUser:withError:` to the callback\n block of `signInWithConfiguration:presentingViewController:callback:`.\n\n - Move the logic from `signIn:didDisconnectWithUser:withError:` to the\n callback block of `disconnectWithCallback:`.\n\n- Manually connect `GIDSignInButton` to a method that calls\n `signInWithConfiguration:presentingViewController:callback:` using an\n `IBAction` or similar."]]