Skip to content

Commit 70c4b17

Browse files
author
chaoming.edc
committed
2 parents be87bc3 + ecce9fe commit 70c4b17

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,43 @@ WebViewJavascriptBridgeRT
33

44
A WinRT 8.1 [WebViewJavascriptBridge](https://github.com/marcuswestin/WebViewJavascriptBridge), you can send message between C# and JS with WebView.
55

6+
HOW TO?
7+
------------
8+
9+
To use a `WebViewJavascriptBridge`, please follow these steps.
10+
11+
12+
## First
13+
14+
Create a bridge instance, pass your target WebView.
15+
16+
``` C#
17+
18+
var bridge = new WebViewJavascriptBridge(TestWebView, (data, callback) =>
19+
{
20+
Debug.WriteLine(@"Receive message from JS: " + data);
21+
callback(@"Response for message from C#");
22+
});
23+
24+
```
25+
26+
## Register native function for your JS
27+
28+
29+
``` C#
30+
31+
bridge.RegisterHandler(@"testCSharpCallback", (data, callback) =>
32+
{
33+
Debug.WriteLine(@"Receive message from JS: " + data);
34+
callback(@"Response from testCSharpCallback");
35+
});
36+
37+
```
38+
39+
Then you can call C# code by sending `testCSharpCallback` string to native.
40+
41+
42+
643
What's next?
744
------------
845

0 commit comments

Comments
 (0)