Nathan H Nathan H - 2 months ago 53
iOS Question

Receive message from JavaScript WebView in Objective-C

I have a WebView with a JavaScript function

, that makes some ajax calls.

In my AppDelegate, I've managed to to use WebView's stringByEvaluatingJavaScriptFromString to execute loadStuff.

Now my problem is I want to execute some Objective-C code once the JavaScript ajax stuff is done. How can my JavaScript notify back the native code?


If you have access to your AJAX success handler, you can just force webview to open some fake url from it and then handle this from delegate's shouldStartLoadWithRequest.