flutter_inappwebview
flutter_inappwebview copied to clipboard
Question regarding javascript communication
I wanted to verify that I draw the right conclusions from the documentation:
-
Depending on when a script is loaded, it is possible that
window.flutter_inappwebviewis not yet set. -
In that case we should listen to the
flutterInAppWebViewPlatformReadyevent, in order to know about the earliest point in time, when we are able to make those calls towindow.flutter_inappwebview.callHandler. -
If we are confident enough that calls to
window.flutter_inappwebview.callHandleronly happen after the event, we can also just check ifwindow.flutter_inappwebviewor evenwindow.flutter_inappwebview.callHandleris set before calling it. If it is truthy, we can make the call. -
If we are not sure we can reliably listen to the
flutterInAppWebViewPlatformReadyevent, 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
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!
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.