OGeek|极客世界-中国程序员成长平台

标题: ios - iOS Ionic 应用程序中的链接未立即打开 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 13:18
标题: ios - iOS Ionic 应用程序中的链接未立即打开

我的应用程序的一个 View 中有几个链接:

  1. 分享
  2. 添加到日历
  3. 打开外部链接

在我用来测试应用程序的 iPhone 上,1 和 2 工作,但只有当我按下主页按钮然后返回应用程序时,才会出现共享/日历对话框。谁能建议可能导致这种情况的原因?我什至不知道在哪里看。

外部链接使用 window.open(url, "_system") 因为我无法让常规类型的链接在模拟器中工作。我可能会切换回常规的 HTML 链接,因为另一个链接能够在测试 iPhone 上工作。使用 iOS 在手机浏览器中打开链接的建议方法是什么?

代码大致如下。

.controller('WCtrl', function ($scope, $stateParams, $sce) {
  // ...
  $scope.doShare = function () {
    var options = {
      message: 'Message here',
      subject: 'Event shared'
    };
    var onSuccess = function (result) {
      console.log('Share successful.');
    };
    var onError = function (msg) {
      console.log('Sharing failed with message: ' + msg);
    }
    window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);
  };
  $scope.doCalAdd = function () {
    var onSuccess = function (result) {
      console.log('Add to calendar successful.');
    };
    var onError = function (msg) {
      console.log('Add to calendar failed with message: ' + msg);
    }
    // ...
    window.plugins.calendar.createEventInteractively(
      title,
      location,
      notes,
      starttime,
      endtime,
      onSuccess,
      onError);
  };
  $scope.doTicketsOpen = function () {
    var url = w.ticketing;
    window.open(url, '_system');
  };
})
<ion-view class="item-text-wrap" view-title="Event Details">
  <ion-content class="has-footer">
    <!-- ... -->
  </ion-content>
  <ion-footer-bar>
    <div class="button-bar">
      <div class="button icon ion-share" ng-click="doShare();">Share</div>
      <div class="button icon ion-calendar" ng-click="doCalAdd();">Calendar</div>
      <div class="button icon ion-link" ng-click="doTicketsOpen();">Ticketing</div>
    </div>
  </ion-footer-bar>
</ion-view>


Best Answer-推荐答案


您必须在 index 的 Content-Security-Policy 元标记的 default-src 中添加 gap: .html.

这是因为在 iOS 10 上,Apple 对 CSP 的要求更加严格,而 * 并未涵盖某些内容

关于ios - iOS Ionic 应用程序中的链接未立即打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43326912/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4