This will help you out. There are a couple libraries out there:
if you’re looking for something small/easy you do this:
- make your own protocol (instead of http:// you would use mike://)
- make a url request, which ultimately is an event you can look for with UIWebView
- process the request in UIWebView and handle any items from your scheme accordingly
and on the objective-c side:
The reason you use iframes instead of “window.location” is because there are limits to how fast you can call window.location. However, if you load iframes and dump the objects out of the document after creation, it negates the url request limit. There are similar hacks all over dealing with ddos attacks that use a similar approach, and in this case allows you to call objective c much more often.
Also, props to this guy.
So for this you can actually execute functions and shit from objective-c. You just need to make sure the function calls are in the right scope, so if you have something defined in window it would just be:
Usually, you will want to execute these functions after the window has had a chance to load so:
Then on the front end, have an alert or something to show you it worked: