Issue with webview two way communication bridge on WPF platform
Environment
react-native -v: react-native-cli: 2.0.1 react-native: 0.55.4
npm ls rnpm-plugin-windows: [email protected]
npm ls react-native-windows: [email protected]
node -v: v6.11.1
npm -v: 3.10.10
yarn --version:
Then, specify:
Target Platform: WPF Target Platform Version(s): .NET 4.6.0 WPF Target Device(s): Desktop Development Operating System: Windows 10 Pro version: 1709 Visual Studio Version: 2017
Steps to Reproduce
(Write your steps here:)
- react-native init test
- cd test
- npm install --save-dev rnpm-plugin-windows
- npm install react-native
- react-native wpf
- react-native run-wpf
- Modify code to include webview and communicate using webview bridge to establish two way communication betqween react-native and webview [code attached]
Expected Behavior
Code under Webview's 'onMessage' should get called when message send from webview using 'postMessage'
Actual Behavior
When message sent from react-native to webview it works fine but when message sent from webview to react-native it doesn't work i.e. technically Webview component's 'injectedJavaScript' attribute works but 'onMessage' never gets called
<WebView source = {testFile} injectedJavaScript={'messageFromRN()'} onNavigationStateChange={(navEvent)=> console.log(navEvent.jsEvaluationValue)} onMessage={(event)=> console.log(event.nativeEvent.data)} style={{flex: 1}} />
Reproducible Demo
Code with important files attached which can be added to any wpf based sample project. Instructions:
- replace App.windows.js and
- copy src folder
@matthargett Any comment on this issues like its a known issue, it is in plan something like that?
FYI UWP also has an issue below is my observation:
- UWP: WebView's 'injectedJavaScript' doesn't work but 'onMessage' is working fine
- WPF: 'injectedJavaScript' is working but 'onMessage' doesn't work
Let me know if I am not clear any need more details about this issue.
We are not investing in new features or lower priority bug fixes on vCurrent. The bulk of investment is now in vNext as we prepare to make that the default choice. If this issue is still relevant on the vNext implementation please open a vNext issue. If this issue is of significant severity for a vCurrent app and vNext is not an option, re-open with justification.
@matthargett Any comment on this issues like its a known issue, it is in plan something like that?
FYI UWP also has an issue below is my observation:
- UWP: WebView's 'injectedJavaScript' doesn't work but 'onMessage' is working fine
- WPF: 'injectedJavaScript' is working but 'onMessage' doesn't work
Let me know if I am not clear any need more details about this issue.
please may i know how to inject in WPF? any sample great help? WPF: 'injectedJavaScript' is working but 'onMessage' doesn't work