Solvedreact native webview bridge [Android] injectScript not work!
16 Answers
Share
Original✔️Accepted Answer
I experienced something interesting.
My script works on iOS but applying it to android did not work.
first
as @g6ling suggested watch examplesecond
—that is what is interesting— erase all javascript comments in your scripts!!!- it broke my script on android!!! It was why it did not work...
Illustration:
const scriptNotWorking = `
// a comment <= erase all comments like this one!!!
alert('it won\'t work');
`;
const scriptWorking = `
alert('it will work');
`;
Related Issues:
9
react native webview bridge [Android] injectScript not work!
I experienced something interesting My script works on iOS but applying it to android did not work ...
I write bellow code:
function webViewBridgeReady(cb) {
if (window.WebViewBridge) {
cb(window.WebViewBridge);
return;
}
}
function goDetail(id) {
WebViewBridge.send("jump:" + id);
}
webViewBridgeReady(function (webViewBridge) {
webViewBridge.send("message from webview");
});
the html is get from server, html have a button and click to invoke the goDetail function,but in android the
log cat say 'goDetail is not defined'.
can you help me?