React Native WebView onMessage stopped working in latest Chome Android build
up vote
0
down vote
favorite
I have an app that uses web views to render forum posts in html. I've injected script to calculate the height of these web views after the content is loaded.
This has worked fine until the end of October 2018 and seems to be related to a recent update of Chrome.
I can still see that my scripts in the web views run and calculates the height. These use window.postMessage. But in the react native side the onMessage of the web view never gets the message.
Any idea why?
add a comment |
up vote
0
down vote
favorite
I have an app that uses web views to render forum posts in html. I've injected script to calculate the height of these web views after the content is loaded.
This has worked fine until the end of October 2018 and seems to be related to a recent update of Chrome.
I can still see that my scripts in the web views run and calculates the height. These use window.postMessage. But in the react native side the onMessage of the web view never gets the message.
Any idea why?
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an app that uses web views to render forum posts in html. I've injected script to calculate the height of these web views after the content is loaded.
This has worked fine until the end of October 2018 and seems to be related to a recent update of Chrome.
I can still see that my scripts in the web views run and calculates the height. These use window.postMessage. But in the react native side the onMessage of the web view never gets the message.
Any idea why?
I have an app that uses web views to render forum posts in html. I've injected script to calculate the height of these web views after the content is loaded.
This has worked fine until the end of October 2018 and seems to be related to a recent update of Chrome.
I can still see that my scripts in the web views run and calculates the height. These use window.postMessage. But in the react native side the onMessage of the web view never gets the message.
Any idea why?
asked Nov 8 at 21:37
Johan Nordberg
1,78922141
1,78922141
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Ok so I found the error. The problem seems to be that the signature for Chromes native postMessage method and the version that React Native replaces it with are the same now, so the common fix to check if window.postMessage.length === 1 to know when RN is ready does not work. My solution was to check if typeof window.originalPostMessage === 'undefined' instead. When originalPostMessage is set, RN is ready.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Ok so I found the error. The problem seems to be that the signature for Chromes native postMessage method and the version that React Native replaces it with are the same now, so the common fix to check if window.postMessage.length === 1 to know when RN is ready does not work. My solution was to check if typeof window.originalPostMessage === 'undefined' instead. When originalPostMessage is set, RN is ready.
add a comment |
up vote
0
down vote
Ok so I found the error. The problem seems to be that the signature for Chromes native postMessage method and the version that React Native replaces it with are the same now, so the common fix to check if window.postMessage.length === 1 to know when RN is ready does not work. My solution was to check if typeof window.originalPostMessage === 'undefined' instead. When originalPostMessage is set, RN is ready.
add a comment |
up vote
0
down vote
up vote
0
down vote
Ok so I found the error. The problem seems to be that the signature for Chromes native postMessage method and the version that React Native replaces it with are the same now, so the common fix to check if window.postMessage.length === 1 to know when RN is ready does not work. My solution was to check if typeof window.originalPostMessage === 'undefined' instead. When originalPostMessage is set, RN is ready.
Ok so I found the error. The problem seems to be that the signature for Chromes native postMessage method and the version that React Native replaces it with are the same now, so the common fix to check if window.postMessage.length === 1 to know when RN is ready does not work. My solution was to check if typeof window.originalPostMessage === 'undefined' instead. When originalPostMessage is set, RN is ready.
answered Nov 9 at 7:57
Johan Nordberg
1,78922141
1,78922141
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53216513%2freact-native-webview-onmessage-stopped-working-in-latest-chome-android-build%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown