Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
比較 Metamask 用的 reaect native webview 跟 flutter_inappwebview 後,發現主要的差別在 inject 的 script 會被經過不同的處理才丟到 Android 的 evaluateJavascript
原本 flutter_inappwebview 裡的寫法,如果 inject 的當下 document.readyState = 'loading' 的話,script 就完全不會執行。把這個 template 改成 metamask 用的 IIFE 的寫法就會 work 了
主要參考:https://github.com/react-native-webview/react-native-webview/blob/master/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java#L284-L290