I am developing an iOS app using NativeScript using Angular. I have a webview in it. I want to delete all the cookies on click of a button. How to do it?
for iOs you can user following code to delete each cookies inside the IOs WebView.
const cookies: any = NSHTTPCookieStorage.sharedHTTPCookieStorage.cookies;
if (typeof cookies !== 'undefined') {
for (let i = 0; i < cookies.count; i++) {
const cookie: NSHTTPCookie = <NSHTTPCookie>cookies.objectAtIndex(i);
// let cookie: any = cookies[i];
console.log(cookie);
NSHTTPCookieStorage.sharedHTTPCookieStorage.deleteCookie(cookie);
}
}
console.log(NSHTTPCookieStorage.sharedHTTPCookieStorage.cookies);
After the last console.log there shouldn't be any Cookies.
Kind regards