James Hollingworth
James Hollingworth

Reputation: 14210

Accessing WebScriptObject with MonoTouch

I am building a phonegap like solution using MonoTouch & UIWebView. I would like to expose a number of C# methods via Javascript. I know you can do this in Objective C using WebScriptObject but I can't see where/if this is exposed in the MonoTouch API's.

Is there a way to access WebScriptObject?

Upvotes: 1

Views: 317

Answers (3)

Stuart
Stuart

Reputation: 66882

As some additional side answers to this...

  • you can access javascriptcore - but you will have to work out the bindings for this
  • some people have managed to use Jint (0.9 or older - with no Reflection.Emit JIT code)

Upvotes: 1

Anuj
Anuj

Reputation: 3134

Just as as corollary to Sebastian's answer you can always create a simple binding that allows your UIWebView to interact with C# code via a HttpListener:

http://yobriefca.se/blog/2011/12/05/rolling-your-own-phonegap-with-monotouch/

You can also use iOS Background threads to interact with other apps via Javascript or C# using HttpListener:

http://blog.devnos.com/remember-when-apps-didnt-talk-to-each-other

Upvotes: 1

poupou
poupou

Reputation: 43543

Is there a way to access WebScriptObject?

No, WebScriptObject is not part of MonoTouch (like it is part in MonoMac) since WebKit, as a framework, is not part of iOS.

UIWebView does allow you to evaluate JavaScript code but I'm not sure (never tried or even looked for) how you can, from there, get back into C# methods.

Upvotes: 2

Related Questions