jfan29
September 29, 2017, 11:36pm
1
I’ve been stuck for 2 days now trying to figure out how to pass data from swift to the WKwebview that contains the ionic application(hybrid)
I know that in ios we can evaluate a js function thus running it.
Swift
webView.evaluateJavaScript("PassDataToJavascript()");
Javascript
build/main.js ==>l.prototype.PassDataToJavascript()
doesn't allow us to see the evaluate PassDataToJavascript()
How do you guys communicate between native and hybrid(webview)
jfan29
September 29, 2017, 11:37pm
2
Anyways to expose the js function in build/main.js to window object so we can call it from IOS?
Sujan12
September 30, 2017, 7:52am
3
So you are not containing your Ionic app in a common Cordova based app?
In general: Look at any of the Cordova plugins. Communicating between native and Ionic is exactly what they do.
1 Like
jfan29
October 6, 2017, 5:26pm
4
Thanks I was able to pass data with this method : (window).favList=[]; hopefully it will help anyone in the future!
Can you explain a bit more how exactly you used this please?
jfan29
October 6, 2017, 11:16pm
6
(<any>window).mydata;
…
…
my function()
{
//GOT SOME DATA someData
mydata = somedata;
}
then you can have access to mydata from the window object from chrome console or ios evaluate this window.mydata
Can you explain this please? I am not understand. (<any>window).mydata;
is the Swift code? Where to use this?
Please open a new forum post. Commenting on a 4+ year old post is probably not going to be the best way to get help