iOS Ionic app中的链接无法立即打开

时间:2017-04-10 15:14:18

标签: ios cordova ionic-framework

我的应用中的一个视图中有一些链接:

  1. 共享
  2. 添加到日历
  3. 打开外部链接
  4. 在我用来测试应用程序的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>
    &#13;
    &#13;
    &#13;

    我在index.html中有一个Content-Security-Policy元标记,如下所示。

    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />
    

1 个答案:

答案 0 :(得分:3)

您必须在gap:的{​​{1}}元标记的default-src中添加Content-Security-Policy

这是因为在iOS 10上,Apple对CSP更加严格,index.html并未涵盖某些内容