cordova-plugin-inappbrowser
cordova-plugin-inappbrowser copied to clipboard
@3.2.0 can't call webkit.messageHandlers.cordova_iab.postMessage
when I want to call webkit.messageHandlers.cordova_iab.postMessage on my webpage.htm, window.webkit is undefined, but it can work on @3.1.0 inappbrowser.....
so, I try to find reason, if I want to use post message, I have to do ... var ref=window.open ('http://xxxx/mypage.htm') // I must call this, so my page.htm can use webkit.messageHandlers.... ref.addEventListener('loadstone', function (){ ref.execJavaScript(';')});
You have to check below
- Are you using wkwebview instead of uiwebview In my opinion, wkwebview can handle message but uiwebview isn't
- At webpage javascript, use this code
window.webkit.messageHandlers.cordova_iab_postMessage("message");
After I write 'window.webkit' instaed of just 'webkit', my code was worked
loadstone isn't a valid event, too.
In general: Thanks a lot for your issue, however the issue template exists for a reason. 😊.
It helps us to debug the issue further and to provide a solution much faster. With important information missing, we unfortunately can't help you.
Therefore, please edit this issue accordingly or close and create a new one and make sure to provide all the required information.
@LouiMinister I am using the same code as you posted but receiving "TypeError: window.webkit.messageHandlers.cordova_iab_postMessage is not a function" on both iOS and Android. Previously this code used to work fine: "webkit.messageHandlers.cordova_iab.postMessage(message)", but with latest preferences set on wkwebview its not working. Do you have any solutions/workaround for this?
any updates here? iab.postMessage is undefined, executeScript also not working in iOS