4

I'm building an app for Android and iOS using Cordva (v3.3.0) and JQuery Mobile. Now I'm trying to use the InAppBrowser plugin. On Android this works fine but on iOS the webpage seems to open in the Cordova WebView and not in the system browser. The problem ist that it is not possible to return to the app as soon as the browser is opened because there is no location bar / back button.

I already tryed to remove the plugin and to add it again and I also updated Cordova to the latest Version (3.3.0)

Can anybody help me to find the Bug?

Thanks!

config.xml

<access origin="*" />
<feature name="InAppBrowser">
    <param name="ios-package" value="CDVInAppBrowser" />
</feature>

index.html

<a href="#" onclick="window.open('http://google.com', '_system', 'location=yes');" data-role="button" data-icon="arrow-r" data-iconpos="right">Google</a>

Log Output

Resetting plugins due to page load.
Finished load of: https://www.google.ch/?gws_rd=cr&ei=hj31Up7fEYXgygXXXXXXXX
Samuel Wicky
  • 310
  • 1
  • 2
  • 10

3 Answers3

6

Just found the solution.

The following entry was missing in the iOS cordova_plugins.js File. In Android it was available....

{
    "file": "plugins/org.apache.cordova.core.inappbrowser/www/InAppBrowser.js",
    "id": "org.apache.cordova.core.inappbrowser.InAppBrowser",
    "clobbers": [
        "window.open"
    ]
},
Samuel Wicky
  • 310
  • 1
  • 2
  • 10
  • Nice find! Note that `org.apache.cordova.inappbrowser` isn't in the `module.exports.metadata` hash in that file, either. Unfortunately, `platforms/ios/www/cordova_plugins.js` is automatically generated and any changes I make to it are replaced when I do a build. Additionally, `plugins/org.apache.cordova.inappbrowser/plugin.xml` appears to define the `clobbers` array for iOS correctly. This is puzzling. – James Mar 10 '15 at 19:58
  • Resolved for me. When I removed all plugins except for InAppBrowser, `cordova_plugins.js` was updated correctly. Then I added plugins back one at a time, checking `cordova_plugins.js` after each compile until I found the plugin that triggered the bug. Not sure how to fix the plugin, but I wasn't using it anymore anyway. – James Mar 10 '15 at 22:29
  • where is the cordova_plugins file located? – AN11 May 17 '17 at 13:02
1

You should change page meta in header to

<meta http-equiv="Content-Security-Policy" content="img-src * 'self' data:; default-src * 'self' gap: wss: ws: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval';">

It works for me.

vitralyoz
  • 570
  • 7
  • 14
0

For me the issue was with Visual Studio Cordova tools. I updated Cordova CLI to 5.1.1 however in visual studio config.xml > Platform section I still had 4.3.3. So when I used the latest inappbrowser with the new name cordova-plugin-inappbrowser is was causing it not to work.

So if you're using Visual Studio make sure the version in config.xml is the same as the command line. (use cordova -version to get the correct version)

parliament
  • 21,544
  • 38
  • 148
  • 238