flutter_inappwebview icon indicating copy to clipboard operation
flutter_inappwebview copied to clipboard

Question regarding javascript communication

Open karfau opened this issue 3 years ago • 2 comments

I wanted to verify that I draw the right conclusions from the documentation:

  1. Depending on when a script is loaded, it is possible that window.flutter_inappwebview is not yet set.

  2. In that case we should listen to the flutterInAppWebViewPlatformReady event, in order to know about the earliest point in time, when we are able to make those calls to window.flutter_inappwebview.callHandler.

  3. If we are confident enough that calls to window.flutter_inappwebview.callHandler only happen after the event, we can also just check if window.flutter_inappwebview or even window.flutter_inappwebview.callHandler is set before calling it. If it is truthy, we can make the call.

  4. If we are not sure we can reliably listen to the flutterInAppWebViewPlatformReady event, we should rely on variant 3 to make those calls, since there is no other way to known wether the callHandler is actually ready.

Let me know if there is another place to post this, or if there is anything unclear. Thx

karfau avatar May 23 '22 20:05 karfau

👋 @karfau

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

github-actions[bot] avatar May 23 '22 20:05 github-actions[bot]

I read through https://inappwebview.dev/docs/javascript/communication/ and I searched in the github issues but didn't find anything similar.

I considered this would be a better place for this specific question than going to/searching stackoverflow / google since I want to verify multiple assumptions I have after reading the documentation and having seen some code, that is based on those assumptions.

karfau avatar May 23 '22 20:05 karfau