Skip to content

Commit abd33ec

Browse files
committed
Fix logout
1 parent bec372a commit abd33ec

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Sources/TeslaSwift/TeslaSwift.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import Foundation
1010
import os
1111
import SafariServices
12+
import WebKit
1213

1314
public enum TeslaError: Error, Equatable {
1415
case networkError(error: NSError)
@@ -305,10 +306,18 @@ extension TeslaSwift {
305306
password = nil
306307
cleanToken()
307308
#if canImport(WebKit) && canImport(UIKit)
308-
TeslaWebLoginViewController.removeCookies()
309+
Self.removeCookies()
309310
#endif
310311
}
311312

313+
static func removeCookies() {
314+
WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
315+
records.forEach { record in
316+
WKWebsiteDataStore.default().removeData(ofTypes: record.dataTypes, for: [record], completionHandler: {})
317+
}
318+
}
319+
}
320+
312321
/**
313322
Create a URL to send your public key to vehicle.
314323
Old Model S and X do not need to call this function

0 commit comments

Comments
 (0)