在Swift或RxAlamofire中退出浏览器会话的方法是通过使用URLCredentialStorage
类来删除保存的凭据。以下是具体的步骤:
WebKit
框架和Alamofire
库:import WebKit
import Alamofire
WKWebsiteDataStore
对象,用于管理浏览器数据:let websiteDataStore = WKWebsiteDataStore.default()
websiteDataStore
对象获取保存的凭据:websiteDataStore.fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
let credentials = records.filter { $0.displayName == "Cookies" }
for credential in credentials {
WKWebsiteDataStore.default().removeData(ofTypes: credential.dataTypes, for: [credential], completionHandler: {})
}
}
URLCredentialStorage
中的凭据:URLCredentialStorage.shared.remove(NSURLCredentialStorage.shared.allCredentials, for: protectionSpace, options: nil)
没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云