We are working on an IOS app that has been developed in swift.
This consists of a webview where in the initial pages are native and then we are moving to webview.
During the transition from the native pages to the webview we need to store some values in the LocalStorage so those can be used in the webview.
This is working in Android but we are facing some problems in IOS. The Android code is as follows:-
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT)
wv_content.evaluateJavascript("localStorage.setItem('" + key + "','" + value + "');", null);
else
wv_content.loadUrl("javascript:localStorage.setItem('" + key + "','" + value + "');");
https://developer.apple.com/icloud/documentation/data-storage/index.html
PhoneGap iOS 7 and localStorage
But none of them has been successful for me. I have googled around and there were no perfect code samples that could have been used to display the way it can be done.
Please help me with a code sample of doing the same with enabling the needed preferences.
Thanks for help.
UPDATE
Below is the IOS code I am using and this way is not working for me.
web_browser.delegate = self
let javaScript = "localStorage.setItem(\"user\", \"\(jsonString!)\")"
web_browser.stringByEvaluatingJavaScript(from: javaScript)
web_browser.loadRequest(URLRequest(url: url!))