Skip to content

Instantly share code, notes, and snippets.

@rolfbjarne
Created Dec 23, 2014
Embed
What would you like to do?
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