我创建了推包带有效证件,并托管在与有效的SSL证书,但问题服务器的JavaScript始终显示被拒绝的消息,甚至提示用户面前。 我使用苹果教程,有效的网站推ID和web服务的URL等方面的Java脚本代码
document.body.onload = function() {
// Ensure that the user can receive Safari Push Notifications.
if ('safari' in window && 'pushNotification' in window.safari) {
var permissionData = window.safari.pushNotification.permission('web.com.example.domain');
checkRemotePermission(permissionData);
}
};
var checkRemotePermission = function (permissionData) {
if (permissionData.permission === 'default') {
// This is a new web service URL and its validity is unknown.
window.safari.pushNotification.requestPermission(
'https://domain.example.com', // The web service URL.
'web.com.example.domain', // The Website Push ID.
{}, // Data that you choose to send to your server to help you identify the user.
checkRemotePermission // The callback function.
);
}
else if (permissionData.permission === 'denied') {
alert('denied');
// The user said no.
}
else if (permissionData.permission === 'granted') {
alert('granted');
// The web service URL is a valid push provider, and the user said yes.
// permissionData.deviceToken is now available to use.
}
};
问题是,我得到了我的javascript“否认”的警报,因为权限被拒绝。 问题是它从来没有问过,也从未问过。 它甚至在我的Safari偏好。
为什么Safari浏览器回归否认,甚至没有要求?