我已经创建了带有有效证书的推送包,并使用有效的 SSL 证书托管在服务器上,但问题是 javascript 总是在提示用户之前显示被拒绝的消息。我正在使用来自 Apple 教程的 Java 脚本代码以及有效的网站推送 ID 和 Web 服务 URL 等
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 中收到“拒绝”警报,因为权限被拒绝。问题是它从未问过,也从未问过。它甚至不在我的狩猎偏好中。
为什么野生动物园返回被拒绝甚至不问?