I met a problem when trying to open a remote page in cordova.
I tried using the InAppBrowser
plugin open remote page no call native method.
I checked the official documentation.
InAppBrowser
does not allow access to local methods, but I need to implement this functionality.
Can you help me get an insight of how can I do this or get an approach of it?
An emulation of the postMessage API has been added to cordova-plugin-inappbrowser for Android & iOS by this PR which enables you to post messages from the page loaded into the InappBrowser Webview back to the main Cordova Webview where your app is running. Using this would enable you to call "native methods" in your app from the page loaded into the InappBrowser.
This functionality is not yet in the latest release version on npm (
v3.0.0
) so you'll need to install the plugin directly off the Github master branch (v3.1.0-dev
):In your Cordova app code you'd add code to listen for messages from the InappBrowser, for example:
Then in the webpage being loaded into the InappBrowser you'd send the message:
If you don't have direct control over the page being loaded into the InappBrowser, you could inject the code to send the message: