You can use:
[self.webView stringByEvaluatingJavaScriptFromString:@"callSomeFunction();"];
Or:
[self writeJavascript:@"doSomeJavaScript"];
If you want to work with Cordova's own event mechanism, you can call cordova.fireDocumentEvent
to fire off JavaScript events (that you could attach to on the JS side):
[self writeJavascript:
[NSString stringWithFormat:@"setTimeout( function() { cordova.fireDocumentEvent('%@_%@', {data:'%@'} ) }, 0);",
ID, event, data]];
If your call into JavaScript could trigger an alert or call into some other native code, it is best to wrap your JS with a setTimeout
, as in the prior example.