iOS Ionic app中的链接无法立即打开 [英] Links in iOS Ionic app not opening immediately

查看:349
本文介绍了iOS Ionic app中的链接无法立即打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a few links in one of the views in my app for:


  1. 分享

  2. 添加到日历

  3. 打开外部链接

在我曾经使用的iPhone上测试应用程序,1和2类工作,但只有当我按下主页按钮,然后返回到应用程序,然后出现共享/日历对话框。谁能提出可能导致这种情况的人?我不确定在哪里看。

On an iPhone which I used to test the app, 1 and 2 sort of work but only if I press the Home button and then return to the app, then the share/calendar dialogs appear. Can anyone suggest what could cause this? I'm not sure where to even look.

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

The external link uses window.open(url, "_system") because I was not able to get regular type links to work in the simulator. I may switch back to regular HTML links though as another link was able to work on the test iPhone. What is the suggested method to open links in the phone's browser using 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>

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

I have a Content-Security-Policy meta tag in the index.html as below.

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


推荐答案

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

You have to add gap: in the default-src of your Content-Security-Policy meta tag in your index.html.

这是因为在iOS 10上,Apple对CSP更加严格,并且 * 不包含某些内容

This is because on iOS 10 Apple got stricter with the CSP, and * doesn't cover some things

这篇关于iOS Ionic app中的链接无法立即打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆