本页详细介绍了 Google 登录 SDK 的主要版本的主要变更。
请按照本指南将您的应用迁移到最新版本的 Google 登录 SDK。请注意,本文档始终提及最新版本。
如需了解详情,请参阅版本说明和 GitHub 上的代码库。
Google 登录 SDK 7.0.0 版
如需从 v7.0.0 之前的 Google 登录 SDK 版本迁移您的应用,请做出以下更改:
在应用的
Info.plist
文件中设置 OAuth 客户端配置。您可以继续在运行时使用GIDConfiguration
对象进行设置,但我们不再建议这样做。如需查看示例及更多详情,请参阅入门指南。Info.plist
个密钥说明 GIDClientID
OAuth 客户端 ID GIDServerClientID
用于后端身份验证的服务器 OAuth 客户端 ID GIDHostedDomain
Google Workspace 网域 GIDOpenIDRealm
OpenID 领域 addScopes:
方法已移至 GIDGoogleUser。现在,您应该在身份验证完成后向 GIDGoogleUser 请求授权范围,而不是向 GIDSignIn 请求额外的授权范围。如果您将
serverClientID
设置为为您的应用启用服务器端 API 访问权限,则现在将在完成过程中返回serverAuthCode
以及GIDSignInResult
。GIDAuthentication
中的属性已移至GIDGoogleUser
。更新方法调用:
v6.2.x | v7.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
协议及其方法的所有引用。将逻辑从
signIn:didSignInForUser:withError:
移至signInWithConfiguration:presentingViewController:callback:
的回调块。将逻辑从
signIn:didDisconnectWithUser:withError:
移至disconnectWithCallback:
的回调块。
手动将
GIDSignInButton
连接到使用IBAction
或类似方法调用signInWithConfiguration:presentingViewController:callback:
的方法。