Skip to content

Instantly share code, notes, and snippets.

@rolfbjarne
Created December 23, 2014 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolfbjarne/5d3bab08ed88bff9db88 to your computer and use it in GitHub Desktop.
Save rolfbjarne/5d3bab08ed88bff9db88 to your computer and use it in GitHub Desktop.
public void JSExportTest ()
{
var webView = new UIWebView ();
var context = (JSContext) webView.ValueForKeyPath ((NSString) "documentView.webView.mainFrame.javaScriptContext");
context.ExceptionHandler = (JSContext context2, JSValue exception) =>
{
Console.WriteLine ("JS exception: {0}", exception);
};
var obj = new MyJavaExporter ();
context [(NSString) "obj"] = JSValue.From (obj, context);
context.EvaluateScript ("obj.myFunc ();");
}
[Protocol ()]
interface IMyJavaExporter : IJSExport {
[Export ("myFunc")]
void MyFunc ();
}
class MyJavaExporter : NSObject, IMyJavaExporter
{
public void MyFunc ()
{
Console.WriteLine ("Called!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment