3

launch-external does not seems to work for iOS. but it works perfectly for android.

I am looking for a 'launch-external' equivalent for iOS, i am using cardova (version 3.7.0) and phoneGap online build tool.

below is my config.xml

<widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.something.something" version="1.0.3">
  <name>something</name>
  <description>
something
  </description>
  <author href="http://something.com" email="something@something.com">Something</author>
  <content src="index.html"/>
  <preference name="permissions" value="none"/>
  <preference name="orientation" value="default"/>
  <preference name="target-device" value="universal"/>
  <preference name="fullscreen" value="false"/>
  <preference name="webviewbounce" value="false"/>
  <preference name="prerendered-icon" value="true"/>
  <preference name="stay-in-webview" value="false"/>
  <preference name="ios-statusbarstyle" value="black-opaque"/>
  <preference name="detect-data-types" value="true"/>
  <preference name="exit-on-suspend" value="true"/>
  <preference name="show-splash-screen-spinner" value="true"/>
  <preference name="auto-hide-splash-screen" value="true"/>
  <preference name="disable-cursor" value="false"/>
  <preference name="android-minSdkVersion" value="7"/>
  <preference name="android-installLocation" value="auto"/>
  <preference name="DisallowOverscroll" value="true" />

  <gap:plugin name="org.apache.cordova.console"/>
  <gap:plugin name="org.apache.cordova.device"/>
  <gap:plugin name="org.apache.cordova.dialogs"/>
  <gap:plugin name="org.apache.cordova.geolocation"/>
  <gap:plugin name="org.apache.cordova.globalization"/>
  <gap:plugin name="org.apache.cordova.inappbrowser"/>
  <gap:plugin name="org.apache.cordova.network-information"/>
  <gap:plugin name="org.apache.cordova.vibration"/>
  <gap:plugin name="org.apache.cordova.statusbar"/>
  <gap:plugin name="org.apache.cordova.splashscreen"/>

  <icon src="icon.png"/>
  <icon src="res/icon/android/icon-36-ldpi.png" gap:platform="android" gap:qualifier="ldpi"/>
  <icon src="res/icon/android/icon-48-mdpi.png" gap:platform="android" gap:qualifier="mdpi"/>
  <icon src="res/icon/android/icon-72-hdpi.png" gap:platform="android" gap:qualifier="hdpi"/>
  <icon src="res/icon/android/icon-96-xhdpi.png" gap:platform="android" gap:qualifier="xhdpi"/>

  <icon src="res/icon/ios/icon-57.png" gap:platform="ios" width="57" height="57"/>
  <icon src="res/icon/ios/icon-72.png" gap:platform="ios" width="72" height="72"/>
  <icon src="res/icon/ios/icon-57-2x.png" gap:platform="ios" width="114" height="114"/>
  <icon src="res/icon/ios/icon-72-2x.png" gap:platform="ios" width="144" height="144"/>  
    <!-- iPhone 6 / 6+ -->
  <icon src="res/icon/ios/icon-60@3x.png" gap:platform="ios" width="180" height="180" />

  <!-- iPhone / iPod Touch  -->
  <icon src="res/icon/ios/icon-60.png" gap:platform="ios" width="60" height="60" />
  <icon src="res/icon/ios/icon-60@2x.png" gap:platform="ios" width="120" height="120" />

  <!-- iPad -->
  <icon src="res/icon/ios/icon-76.png" gap:platform="ios" width="76" height="76" />
  <icon src="res/icon/ios/icon-76@2x.png" gap:platform="ios" width="152" height="152" />

  <!-- Settings Icon -->
  <!--
  <icon src="res/icon/ios/icon-small.png" gap:platform="ios" width="29" height="29" />
  <icon src="res/icon/ios/icon-small@2x.png" gap:platform="ios" width="58" height="58" />
  -->
  <!-- Spotlight Icon -->
  <!--
  <icon src="res/icon/ios/icon-40.png" gap:platform="ios" width="40" height="40" />
  <icon src="res/icon/ios/icon-40@2x.png" gap:platform="ios" width="80" height="80" />
  -->

  <platform name="ios">
    <!-- images are determined by width and height. The following are supported -->
    <splash src="res/screen/ios/Default~iphone.png" width="320" height="480"/>
    <splash src="res/screen/ios/Default@2x~iphone.png" width="640" height="960"/>
    <splash src="res/screen/ios/Default-Portrait~ipad.png" width="768" height="1024"/>
    <splash src="res/screen/ios/Default-Landscape~ipad.png" width="1024" height="768"/>
    <splash src="res/screen/ios/Default-568h@2x~iphone.png" width="640" height="1136"/>
  </platform>


  <access origin="sms:*" launch-external="yes" />
  <access origin="geo:*" launch-external="yes" />
  <access origin="mailto:*" launch-external="yes" />
  <access origin="tel:*" launch-external="yes" />
  <access origin="http://*" launch-external="yes" />


  <plugin name="cordova-plugin-whitelist"/>
  <allow-intent href="http://*/*"/>
  <allow-intent href="https://*/*"/>
  <allow-intent href="tel:*"/>
  <allow-intent href="sms:*"/>
  <allow-intent href="mailto:*"/>
  <allow-intent href="geo:*"/>
  <platform name="android">
    <allow-intent href="market:*"/>
  </platform>
  <platform name="ios">
    <allow-intent href="itms:*"/>
    <allow-intent href="itms-apps:*"/>
  </platform>
</widget>

I am using location.href in index.html to open the url in separte browser. This is working in Android as expected but not in iOS

anmol agarwal
  • 51
  • 1
  • 8
  • http://stackoverflow.com/a/30397786/2769095 this may be helpful. I used something similar and it worked very well – OliverJ90 Sep 03 '15 at 02:48
  • thanks @Oliver. But i am not using cardova CLI for build, instead using phoneGap online build. Hence i do not have access to the .m files. I was hoping this to be much simpler. – anmol agarwal Sep 03 '15 at 15:07

2 Answers2

2

In the documentation, launch-external is only mentioned in the Android section. That's probably why it doesn't work for iOS.

As an alternative, you could use the InAppBrowser plugin (don't be fooled by its name) to open certain links externally, but this requires you to rewrite those links to window.open calls, with the target parameter set to _system.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
  • 1
    thanks for your reply, but i am looking for an app level solution and not just for some hand picked links. So i am looking for something at app configuration level. – anmol agarwal Sep 03 '15 at 14:48
  • 1
    I don't think there is an app level solution other than using inAppBrowser plugin – jcesarmobile Sep 08 '15 at 11:39
0

I tried all of these suggestions in a recent iOS build and the only thing that worked for me was the InAppBrowser plugin and changing the code to window.open(href,"_system");