Skip to content

Commit 14e18a2

Browse files
committed
fixed example for android
1 parent 19ef9a7 commit 14e18a2

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

examples/SampleRN20/app.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,27 @@ const injectScript = `
1919
if (WebViewBridge) {
2020
2121
WebViewBridge.onMessage = function (message) {
22-
alert(message);
22+
if (message === "hello from react-native") {
23+
WebViewBridge.send("got the message inside webview");
24+
}
2325
};
2426
2527
WebViewBridge.send("hello from webview");
26-
27-
} else {
28-
window.location.href = "yahoo.ca";
2928
}
3029
}());
3130
`;
3231

3332
var Sample2 = React.createClass({
3433
onBridgeMessage: function (message) {
35-
if (message == "hello from webview") {
36-
console.log(message);
37-
this.refs.webviewbridge.sendToBridge("hello from react-native");
34+
const { webviewbridge } = this.refs;
35+
36+
switch (message) {
37+
case "hello from webview":
38+
webviewbridge.sendToBridge("hello from react-native");
39+
break;
40+
case "got the message inside webview":
41+
console.log("we have got a message from webview! yeah");
42+
break;
3843
}
3944
},
4045
render: function() {

0 commit comments

Comments
 (0)