react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Issue with webview two way communication bridge on WPF platform

Open praveen4zenith opened this issue 8 years ago • 3 comments

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:)

  1. react-native init test
  2. cd test
  3. npm install --save-dev rnpm-plugin-windows
  4. npm install react-native
  5. react-native wpf
  6. react-native run-wpf 
  7. 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:

  1. replace App.windows.js and
  2. copy src folder

code.zip

praveen4zenith avatar Jun 04 '18 18:06 praveen4zenith

@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:

  1. UWP: WebView's 'injectedJavaScript' doesn't work but 'onMessage' is working fine
  2. WPF: 'injectedJavaScript' is working but 'onMessage' doesn't work

Let me know if I am not clear any need more details about this issue.

praveen4zenith avatar Jun 13 '18 09:06 praveen4zenith

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.

ghost avatar Oct 25 '19 21:10 ghost

@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:

  1. UWP: WebView's 'injectedJavaScript' doesn't work but 'onMessage' is working fine
  2. 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

nagisetty1 avatar Jun 16 '22 05:06 nagisetty1