I am doing an iOS hybrid app using swift 2 and HTML/Javascript. I have a native shell which get some information from the calendar and the GPS. I would like to display those information in my WKWebView and update them every seconds. I am working with local HTML.
I have found some example showing how to communicate between the native code and the JS but nothing on how to transfer my "native" datas and display them in the web view. Thanks.
You should ask the Location Manager to update the location for you instead of setting up a 1-second
NSTimer
to do it yourself. And to pass data to Javascript, you can useevaluateJavaScript
method ofWKWebView
:And
my_page.html
:If you are testing this in the Simulator, choose Debug > Location > City Run to see it update continuously (as if you are running through a park).