本頁面提供 Google 登入 SDK 主要版本的重要異動資訊。
請按照本指南的說明,將應用程式遷移至最新版的 Google Sign-In SDK。請注意,說明文件一律是指最新版本。
詳情請參閱版本資訊和 GitHub 上的存放區。
Google 登入 SDK 7.0.0 以上版本
如要從 7.0.0 之前的 Google 登入 SDK 遷移應用程式,請進行下列變更:
在應用程式的
Info.plist檔案中設定 OAuth 用戶端設定。您可以繼續在執行階段 (使用GIDConfiguration) 物件設定這個項目,但我們不建議這麼做。如需相關範例和更多詳情,請參閱入門指南。Info.plist組金鑰說明 GIDClientIDOAuth 用戶端 ID GIDServerClientID用於後端驗證的伺服器 OAuth 用戶端 ID GIDHostedDomainGoogle Workspace 網域 GIDOpenIDRealmOpenID 領域 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 版
如要從 6.0.0 之前的 Google 登入 SDK 版本遷移應用程式,請進行下列變更:
更新對
GIDSignIn.sharedInstance屬性存取的所有[GIDSignIn sharedInstance]呼叫。將所有用戶端設定 (用戶端 ID 等) 移至
GIDConfiguration物件。將呼叫更新為已移除方法的對應值:
v5.x.x v6.0.0 signInsignInWithConfiguration:presentingViewController:callback:restorePreviousSignInrestorePreviousSignInWithCallback:disconnectdisconnectWithCallback:getTokensWithHandler:doWithFreshTokens:refreshTokensWithHandler:doWithFreshTokens:移除所有
GIDSignInDelegate通訊協定及其方法的參照。將邏輯從
signIn:didSignInForUser:withError:移至signInWithConfiguration:presentingViewController:callback:的回呼區塊。將邏輯從
signIn:didDisconnectWithUser:withError:移至disconnectWithCallback:的回呼區塊。
使用
IBAction或類似項目手動將GIDSignInButton連結至呼叫signInWithConfiguration:presentingViewController:callback:的方法。