I want to accept cookies in WebView, but get error
Uncaught Error: SECURITY_ERR: DOM Exception 18
The problem occures just in local js file. As Android docs say, I must use setAcceptFileSchemeCookies
But it doesn't solve my problem. I don't know what I'm doing wrong.
whole list of code:
protected override void OnCreate(Bundle bundle) {
try {
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
_webView = FindViewById<WebView>(Resource.Id.webview);
string html = string.Empty;
Android.Webkit.CookieManager.SetAcceptFileSchemeCookies(true);
using (var stream = _webView.Context.Assets.Open("res/mobileLogin.html")) {
using (TextReader reader = new StreamReader(stream)) {
html = reader.ReadToEnd();
}
}
_webView.Settings.JavaScriptEnabled = true;
_webView.Settings.AllowFileAccess = true;
_webView.Settings.AllowUniversalAccessFromFileURLs = true;
_webView.SetWebViewClient(new HybridWebViewClient());
_webView.SetWebChromeClient(new WebChromeClient());
_webView.LoadDataWithBaseURL("file:///android_asset/res/", html, "text/html", "UTF-8", null);
Android.Webkit.CookieManager.Instance.SetAcceptCookie(true);
} catch (Exception ex) {
Console.WriteLine(ex.Message);
}
}