3

I have an iPad native application with webviews. How can I call a native function in the webview and pass some JSON data to it?

Devjosh
  • 6,450
  • 4
  • 39
  • 61

2 Answers2

1

You need to use window.External.notify like this following blog mentions

http://www.stevesaxon.me/posts/2011/window-external-notify-in-ios-uiwebview/

Joseph Le Brech
  • 6,541
  • 11
  • 49
  • 84
0

This is a quite similar question to this one:

How to call Objective-C from Javascript?

The two more popular frameworks for doing this are JSBridge (pretty lightweight)

http://code.google.com/p/jsbridge-to-cocoa/

and to some extend PhoneGap as a much more complete solution

http://phonegap.com/ .

I used the first one for some project and I have been pretty happy with it - but maybe it requires some small adaptions because the SBJSON framework it relies on changed while JSBridge was not properly maintained in the meantime.

Community
  • 1
  • 1
Christoph
  • 1,525
  • 1
  • 16
  • 27