Google 登录快速迁移指南

本页详细介绍了 Google 登录 SDK 的主要版本的主要变更。

请按照本指南将您的应用迁移到最新版本的 Google 登录 SDK。请注意,本文档始终提及最新版本。

如需了解详情,请参阅版本说明GitHub 上的代码库

Google 登录 SDK 7.0.0 版

如需从 v7.0.0 之前的 Google 登录 SDK 版本迁移您的应用,请做出以下更改:

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: 的方法。