重要事項:自
2024 年 5 月 1 日起,針對使用常用 SDK (包括 GoogleSignIn-iOS) 的 iOS 應用程式,Apple
規定隱私權資訊清單和簽名。請在 2024 年 5 月 1 日前升級至 GoogleSignIn-iOS 7.1.0 以上版本。按照
升級指南操作。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
撤銷存取權杖並取消連結應用程式
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
強烈建議您提供功能,讓使用者將 Google 帳戶與應用程式取消連結。如果使用者刪除帳戶,您必須刪除應用程式透過 Google API 取得的資訊。
下列程式碼範例示範如何以程式輔助方式,撤銷應用程式代表使用者取得的存取權杖,以及如何將使用者的帳戶與應用程式中斷連結。
Swift
GIDSignIn.sharedInstance.disconnect { error in
guard error == nil else { return }
// Google Account disconnected from your app.
// Perform clean-up actions, such as deleting data associated with the
// disconnected account.
}
Objective-C
[GIDSignIn.sharedInstance disconnectWithCompletion:^(NSError * _Nullable error) {
if (error) { return; }
// Google Account disconnected from your app.
// Perform clean-up actions, such as deleting data associated with the
// disconnected account.
}];
disconnectWithCompletion: 方法除了會中斷帳戶連線及撤銷權杖,還會將使用者登出。呼叫 disconnectWithCompletion: 前,請勿登出使用者。
接著,您可以在回呼區塊中回應成功中斷連線,並在應用程式或後端程式碼中觸發任何適當的邏輯。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2026-05-13 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2026-05-13 (世界標準時間)。"],[],[]]