I’m making an iOS app that gets content from a website. This website allows to vote for content through a JS script that is called when a link is clicked in the web page.
I would like to implement voting in my app without having to show the webpage to the user and asking im to click on vote.
I know it is possible to execute a javascript function of a UIWebView using
[myWebView stringByEvaluatingJavaScriptFromString:@"myJSFunction()"]
But loading a UIWebView is a bit long, specially since it’s just to vote (should be fast), isn’t there an easier way to just call for the JS function without requiring user interarction (except taping the vote button in the app, of course)
Thanks !
On iOS that function is the only way to execute a JS function.
Are you talking about using a native UI to enter some vote info, but processing the info gets done by the JS?
It depends upon what the JS is doing i.e. if its interacting with the dom etc., but you may not necessarily have to wait for the UIWebView to have finished downloading/loading/rendering the web page before you can call stringByEvaluatingJavaScriptFromString. The JS maybe ready to use immediatly in which case you can call stringByEvaluatingJavaScriptFromString before waiting for webViewDidFinishLoad gets called?