Open singhlovey opened 6 years ago
I am getting similar issue. Works on Android but not iOS, injectJS works but not server side. When I log the try and catch error, I got: ReferenceError: Can't find variable WebViewBridge
react-native 0.57.1 react-native-webview-bridge 0.40.1
Ok, we got it going at the end. I believe it is a timing/initiation issue. What we end up doing is:
React Native:
<WebViewBridge injectedJavaScript="window.configureWebView(WebViewBridge)" />
Web:
window.configureWebView = (vBridge) => { vBridge.onMessage = (data) => { ... } }
@singhlovey I'm with the same problem here. Did you solve this?
Hi anyone solve this?
No, this repo is dead to me. I've migrated completely to https://github.com/react-native-community/react-native-webview which is the new official webview
of RN, it's actively developed and it does everything that react-native-webview-bridge
did. I suggest you to migrate as well.
Hi
I am opening dropbox loin screen in web view bridge. Now when I successfully login to dropbox and got access token I want to send success message back to react native code. I have successfully done this step for android app.
REACT NATIVE CODE :-
onBridgeMessage(message) { const { webviewbridge } = this.refs; console.log("message " + JSON.stringify(message)); switch (message) { case "hello from webview": webviewbridge.sendToBridge("hello from react-native"); break; case "success": AsyncStorage.setItem("socialicon", "dropbox"); this.props.navigator.push({name: 'GoogleSigninExample', index: 0 }); break;
//console.log("we have got a message from webview! yeah"); case "error": AsyncStorage.setItem("socialicon", "dropboxerror"); this.props.navigator.push({name: 'GoogleSigninExample', index: 0 });
break; } }
WEBVIEW CODE :-
This works perfect and I am able to get success message from web view into react native in android app.
But the same does not works for iOS app. I have checked in simulator as well as in real device but script not triggered.
NOTE:- When I inject script from react native using injectedScript props, I am able to get message on server end but I want like the above mentioned.
Please help if anyone have any solution for the same. Please reply ASAP!
Thanks