Receiving "SecurityError (DOM Exception 18): Operation unsafe" error while storing data in localStorage UIWebView

I am developing one Xamarin.Forms application , and in this application I am using WebView to integrate a tier payment gateway and also create a WebViewRenderer to store data in localStorage UIWebView. and I am getting a security error ( SecurityError (DOM Exception 18): Operation unsafe ). Tyro Payment Gateway URL: " https://iclient.test.tyro.com ".

Please see below my code and help me

string subkey = "window.localStorage.setItem('webTta.integrationKey','integrationKey')";
string key ="try { "+subkey +"; } catch (e) {  alert(e);  }";
IntegrationKey = _uiWebView.EvaluateJavascript(key);

      

enter image description here

+3


source to share


1 answer


My problem is resolved. This error occurred while storing data before page load. I solved this problem with EvaluateJavascript method after page load. If you try to call the EvaluateJavascript method on an empty WebView this will also happen.



+2


source







All Articles