react-native-webview: window.ReactNativeWebView is undefined on Android platform, iOS works just fine.

Bug description:

window.ReactNativeWebView is undefined on Android platform, iOS works just fine.

To Reproduce:

Build for both platforms from same project, open Chrome’s DevTool and Safari’s Web Inspector, type window.ReactNativeWebView in the Console section and send it.

Expected behavior:

Webpage JS can call window.ReactNativeWebView.postMessage() on both platform successfully. Further action handled within React Native.

Screenshots/Videos:

Console at the top showing iOS console, bottom is Android console Image showing iOS console at the top, android console at the bottom

Environment:

  • OS: iOS

  • OS version: 14.3

  • react-native version: 0.63.4

  • react-native-webview version: 11.0.2

  • OS: Android

  • OS version: 11

  • react-native version: 0.63.4

  • react-native-webview version: 11.0.2

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 18

Commits related to this issue

Most upvoted comments

same issue

@fpena I do aware that the issue may not related to onNavigationStateChange, I just not sure that if having the prop will affect anything, or if I’m doing it wrongly (I’m new to React Native)

I created an example repo where this can be reproduced.

In iOS, an alert shows up because the website is call callback function. In Android doesn’t happen.

Also, the codesandbox with the web-view behaviour.

cc: @jamonholmgren