Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Ephmeral session or how to clear logged in state in WKWebView after logout?

未关闭
#294 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
ios, swift

调研方向

首先复现 issue 中描述的 login、logout 以及第二次 WKWebView login 流程。跟踪 Google SignIn signOut() 以及 WKWebView、HTTPCookieStorage 和 WKWebsiteDataStore 的处理。完成的标准是:logout 后重新打开的 WKWebView 不再显示之前缓存的 Google 账户。

由索引模型根据 Issue 内容生成。

描述

bug triage

Describe the bug
I'm wondering how to enable ephemeral session using Google SignIn?
Or how to correctly clear cookies in WKWebView after Google SignIn signOut() method?

To Reproduce
Steps to reproduce the behavior:

  1. Login using Google SignIn
  2. Opens WKWebView with no google account signed in (email field is cleared)
  3. After entering credentials and successful login try to logout
  4. Login again
  5. Opens WKWebView with cached google account

Expected behavior
(5) Opens WKWebView with no google account signed in (email field is cleared)

Screenshots
none

Environment

  • Device: iPhone Simulator
  • OS: iOS 16.2
  • Browser: Safari

Additional context
I tried to clear cookies

  1. In iOS Settings-Safari-Clear History and Website Data

  2. Programmatically:

func clearAllCookies() {

         let url = URL(string: "https://accounts.google.com/Logout")!
         UIApplication.shared.open(url, options: [:], completion: nil)

        if let cookies = HTTPCookieStorage.shared.cookies, cookies.count > 0 {
            HTTPCookieStorage.shared.removeCookies(since: .distantPast)
            print("All cookies deleted")
        }
        
        let dataStore = WKWebsiteDataStore.default()
        dataStore.fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
            records.forEach { record in
                dataStore.removeData(ofTypes: record.dataTypes, for: [record], completionHandler: {
                    print("Deleted:", record)
                })
            }
        }
    }

None of the above worked.

主要语言
Objective-C
星标
751
派生
282
平均合并
4 天 20 小时
30 天内合并 PR
11

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

google/GoogleSignIn-iOS 的其他 Issue

查看 google/GoogleSignIn-iOS 的全部 Issue

相似的 Issue

更多 Objective-C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。