【问题标题】:<access origin="http://*" launch-external="yes" /> not working for iOS<access origin="http://*" launch-external="yes" /> 不适用于 iOS
【发布时间】:2015-09-02 17:16:09
【问题描述】:

launch-external 似乎不适用于 iOS。但它适用于 android。

我正在寻找适用于 iOS 的“启动外部”等效项,我正在使用 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 在单独的浏览器中打开 url。这在 Android 中按预期工作,但在 iOS 中不起作用

【问题讨论】:

  • stackoverflow.com/a/30397786/2769095 这可能会有所帮助。我用过类似的东西,效果很好
  • 感谢@Oliver。但我没有使用 cardova CLI 进行构建,而是使用 phoneGap 在线构建。因此我无权访问 .m 文件。我希望这更简单。

标签: ios cordova


【解决方案1】:

documentation中,launch-external只在Android部分提到。这可能是它不适用于 iOS 的原因。

作为替代方案,您可以使用InAppBrowser plugin(不要被它的名称所迷惑)在外部打开某些链接,但这需要您使用target 参数将这些链接重写为window.open 调用设置为_system

【讨论】:

  • 感谢您的回复,但我正在寻找应用级别的解决方案,而不仅仅是一些手工挑选的链接。所以我正在寻找应用配置级别的东西。
  • 我认为除了使用inAppBrowser插件之外没有应用级别的解决方案
【解决方案2】:

我在最近的 iOS 版本中尝试了所有这些建议,唯一对我有用的是 InAppBrowser 插件并将代码更改为 window.open(href,"_system");

【讨论】:

    猜你喜欢
    • 2013-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 2012-06-21
    • 1970-01-01
    相关资源
    最近更新 更多