-
-
Save rolfbjarne/5d3bab08ed88bff9db88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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