【发布时间】:2017-09-05 17:14:19
【问题描述】:
我的应用程序的一个视图中有几个链接:
- 分享
- 添加到日历
- 打开外部链接
在我用来测试应用程序的 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>
我在 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'" />
【问题讨论】:
-
您的 index.html 中是否有 Content-Security-Policy 元标记?有的话可以发一下吗?
-
@jcesarmobile,谢谢我在帖子中添加了它。我也试图朝那个方向搜索。似乎我可能需要添加 gap: in default-src?
-
是的,您必须添加
gap:才能使插件在 iOS 10 上运行,请在此处查看我的回答 stackoverflow.com/questions/43316548/… -
谢谢!你能发布一个答案让我接受吗?
标签: ios cordova ionic-framework