Reputation: 111
We want to use the in-app browser to load an external web site on our Cordova app. We also want to enable the external website to have a control to our Cordova capabilities / plugins, e.g., SMS Plugin.
Is it a feasible solution to call Cordova plugin code on the external website displayed in the in-app browser? If not, is there any workaround to let the external website call Cordova functionalities?
Thanks
Upvotes: 1
Views: 1808
Reputation: 53301
InAppBrowser was designed to now allow access to Cordova plugins, so what you want to do is not possible.
Anyway, if what you want to do is to load an external website in a Cordova app, you don't really need InAppBrowser, there are multiple ways of loading an external website in the Cordova webview.
The easiest is to change the content tag src to point to your external website
<content src="http://www.externalwebsite.com" />
You will probably need to install the whitelist plugin (for Android) and allow navigation to that external website
<allow-navigation href="http://www.externalwebsite.com/*" />
But in case you don't have internet connection, Apple will notice and won't approve your app.
In that case you can keep the content src pointing to index.html and use the network information plugin to detect if there is internet connection or not, and then redirect to the external website with window.location.href = "http://www.externalwebsite.com";
(you still need the whitelist plugin for this)
Upvotes: 3