1
votes

I'm having some trouble getting links to open using the InAppBrowser in iOS with a Phonegap/Cordova set up.

I'm using the default template Cordova provides and adding this line to it:

<a href="#" onclick="cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');">Testing</a>

When I click the link, nothing happens.

However, when I double-tap the iPhone's home button to switch between apps, then the In-app browser opens as expected (in the view where I can see all open apps I see the browser open). If I navigate back to the app, the browser window now fills the screen as expected.

What am I doing wrong that's preventing this from opening without the app losing focus?

2
For what it's worth, I've tried this on two different iPhones to rule out it being a specific device.Verl
Did you ever get a solution for this?Tisch
<a href="#" onclick="cordova.InAppBrowser.open('apache.org', '_blank', 'location=yes');">Testing</a> I believe that '_blank' option could be the problem - iOS has no back button so it is tricky to get back to the activity (in IOS UIWebView)Aleksandar Jovanovic

2 Answers

1
votes

Found the solution - upgrading to the latest version of Cordova (currently 6.4.0) and creating a new app with that version seemed to resolve this.

1
votes

For anyone else who comes across this - the problem is actually caused by iOS failing to trigger the on device ready. This updated meta tag fixed the problem:

<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';">