How to manage cookies with UIWebView in Swift

后端 未结 8 877
心在旅途
心在旅途 2020-12-02 11:53

What about have a topic where people can easily see how to manage cookies in a webview using the new language Swift? If you check in internet you won\'t find anything intere

8条回答
  •  一向
    一向 (楼主)
    2020-12-02 12:11

    Logout for api VKontakte, swift 3+

    let dataStore = WKWebsiteDataStore.default()
    dataStore.fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { (records) in
        for record in records {
            if record.displayName.contains("facebook") {
                dataStore.removeData(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes(), for: [record], completionHandler: {
                    print("Deleted: " + record.displayName);
                })
            }
        }
    }
    

提交回复
热议问题