Search code examples
xamarin.iosuiwebviewxamarin.forms

Getting error "SecurityError (DOM Exception 18): The operation is insecure" when storing data in localStorage of UIWebView


I am developing one sample Xamarin.Forms Application and in this application I'm using WebView for tyro payment gateway integration and also create WebViewRenderer for store data in localStorage of UIWebView. and I'm getting security error (SecurityError (DOM Exception 18): The operation is insecure). Tyro payment gateway web url is "https://iclient.test.tyro.com".

Please have a look 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


Solution

  • My issue is solved. This error was occurring by storing data before loading page. I solved this issue by call EvaluateJavascript method after loading a page. If you try to call an EvaluateJavascript method in blank WebView then it is also occurring.