PhoneGap Build’s apps fails to open links in external browser

Ever since PhoneGap 2.1.0, every application build with PhoneGap Build always opens all links in WebView on Android. No matter what configuration changes has been done. This is a reported issue, but though we already have PhoneGap 2.4.0, nothing has been actually done around this.

Details and some workaround follows.

Solution for iOS

For PhoneGap Build building mobile applications for iOS platform, you can take these steps (adapted from this StackOverflow answer and updated to PhoneGap 2.3.0) to ensure, that your application will open a link in Safari (or other external web browser):

  1. White list your domain or link — i.e. add <access origin=""></access> to config.xml.
  2. Add <preference name="OpenAllWhitelistURLsInWebView" value="No"></preference> to config.xml.
  3. In your application, add target="_blank" to any link, you wish to open in external browser — for example: <a href="" target="_blank"></a>.

It is proven (not by me, buy by many) that this solution works 100% sure under iOS. However, it fails completely on Android.

Situation for Android platform

According to Access Tags blog article, on Android platform target="_blank" attribute is ignored and you use only whitelisting to control, how your link is opened. If you whitelist your link or domain, it will be always opened in WebView (inside your application) and if it is not whitelisted, it will always be opened in external browser.

This is not true for applications build via PhoneGap Build. Currently (PhoneGap 2.4.0), no matter, what you do — whitelist or not your URL, use target="_blank" or not, set OpenAllWhitelistURLsInWebView (ignored under Android?) to no in config.xml or not — PhoneGap Build apps will always open all URLs in WebView.

Currently, for Android platform, the only workaround is to use InAppBrowser object, like that:

var ref ='', '_system', 'location=yes');

You can omit location=yes (third parameter) part as it is its default value and it is ignored with second argument set to _system.

This is the key, solution and workaround. Using with _system parameter will always open your link in external, system-level webbrowser, while your mobile application will be suspended. Once user press back button, system browser will be closed (suspended) and your application restored.

More info is available in PhoneGap Documentation.

Situation for BlackBerry

I have been only able to test this issue on old, hacked 5.0 device, but it turned out, that external links behavior also does not follows Access Tags blog article. It is said, that for not whitelisted links, BlackBerry should prompt, where to open such link. But I was informed, that PhoneGap Build application complies on BlackBerry, that particular link is not whitelisted (put to config files) and refuses to open it anywhere.

Note: You can’t solve this issue with above workaround, as InAppBrowser object is supported only for Android and iOS per current version of PhoneGap.

Final words

As for me, this is completely not acceptable and make apps build with Build nearly unusable on Android. As a user I personally hate applications that opens URLs inside them, not in a browser and I would surely stop using any that would force me to do so.

I don’t know, when can we expect this issue to be finally fixed? But since it’s thread hasn’t been touched for over three months, I don’t expect to have this fixed soon.

Leave a Reply