cordova-plugin-inappbrowser icon indicating copy to clipboard operation
cordova-plugin-inappbrowser copied to clipboard

@3.2.0 can't call webkit.messageHandlers.cordova_iab.postMessage

Open cowboy1967 opened this issue 5 years ago • 4 comments

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(';')});

cowboy1967 avatar Mar 17 '20 09:03 cowboy1967

You have to check below

  1. Are you using wkwebview instead of uiwebview In my opinion, wkwebview can handle message but uiwebview isn't
  2. 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

LouiMinister avatar Mar 18 '20 04:03 LouiMinister

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.

timbru31 avatar Mar 18 '20 11:03 timbru31

@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?

dheeMADev91 avatar May 18 '20 16:05 dheeMADev91

any updates here? iab.postMessage is undefined, executeScript also not working in iOS

templatetuners avatar Jan 27 '23 01:01 templatetuners