launch-external似乎不适用于iOS。但它适用于Android。
我正在寻找iOS的“launch-external”等价物,我正在使用cardova(版本3.7.0)和phoneGap在线构建工具。
下面是我的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>
我在index.html中使用location.href打开separte浏览器中的url。这在Android中按预期工作,但在iOS
中没有答案 0 :(得分:2)
在documentation中,launch-external
仅在Android部分中提及。这可能就是为什么它不适用于iOS。
作为替代方案,您可以使用InAppBrowser plugin(不要被其名称愚弄)在外部打开某些链接,但这需要您重写这些window.open
来电的链接,将target
参数设置为_system
。
答案 1 :(得分:0)
我在最近的iOS版本中尝试了所有这些建议,唯一对我有用的是InAppBrowser插件并将代码更改为window.open(href,“_ system”);