Javascript Safari 推送通知“允许"但总是放在“拒绝"中模式 [英] Javascript Safari Push Notifications "Allowed" but are always put in "Deny" mode

查看:35
本文介绍了Javascript Safari 推送通知“允许"但总是放在“拒绝"中模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 PHP 成功验证我的包并通过端点 /v1/pushPackages/web.com.mywebsite 将其交付给 Safari 后,出现了预期的弹出窗口:

After successfully certify my package with PHP and deliver it to Safari through endpoint /v1/pushPackages/web.com.mywebsite, the so expected popup appeared:

现在发生了三个问题:

  1. 按下允许"后什么都没有触发,控制台是空的,应该打印设备令牌:...";在 granted 条件下.
  2. 退出并重新打开 Safari 后,我去了 Safari >首选项网站 >通知和我的网站具有拒绝"值!
  3. 如果我将值从拒绝"更改为允许"它没有保存.Safari 将恢复为拒绝"

我可以选择项目,然后按删除"按钮,重新启动 Safari,我的网站将再次请求权限,但问题仍然存在.我的日志文件是空的,没有报错!

I can select the item an press the button "Remove", restart the Safari and my website will ask again for permissions, but the problem persists. My log files are empty, no error is thrown!

var checkSafariPermission = function (permissionData)
{
    if (permissionData.permission === 'default')
    {
        window.safari.pushNotification.requestPermission(
            'https://mywebsite.com',
            'web.com.mywebsite',
            {},
            checkSafariPermission
        );
    } else if (permissionData.permission === 'denied')
    {
        console.log('denied');
    } else if (permissionData.permission === 'granted')
    {
        // This is never triggered!
        console.log('Device token: ' + permissionData.deviceToken);
    }
};

var permissionData = window.safari.pushNotification.permission('web.com.mywebsite');
checkSafariPermission(permissionData);

我有路线:

POST /v1/devices/{deviceToken}/registrations/web.com.mywebsite
DELETE /v1/devices/{deviceToken}/registrations/web.com.mywebsite

已准备好接收数据,但我认为 Safari 尚未请求此路由.

Ready to receive data, but I don't think Safari is yet requesting this routes.

官方文档 是这样说的:

重要提示:确保您的网络服务器使用的是真实证书由证书颁发机构颁发,而不是自签名证书.如果您的证书是自签名的,推送通知不会到达您的用户.

Important: Make sure that your web server is using a real certificate issued from a Certificate Authority, not a self-signed certificate. If your certificate is self-signed, push notifications won’t reach your users.

这可能是问题吗?目前我的网站有一个名为Let's Encrypt Authority X3"的证书,数据如下,但不知道是不是自签名证书?

Could this be the problem? Currently my website has an certificate called "Let's Encrypt Authority X3", with the bellow data, but I don't know if this is a self-signed certificate?

Common name: www.mywebsite.com
SANs: mail.mywebsite.com, mywebsite.com, webmail.mywebsite.com, www.mywebsite.com
Valid from November 10, 2020 to February 8, 2021
Serial Number: 046829bc4b1e9d71ed27b...
Signature Algorithm: sha256WithRSAEncryption
Issuer: Let's Encrypt Authority X3


更新 1 - 我刚刚收购了 &安装了证书,问题依旧


UPDATE 1 - I just acquired & installed a certificate, the problem persists

推荐答案

已解决.

这不是 Safari 的问题,但我在 OS X 上使用 Virtual Box 的事实是有问题的.在真正的 macOS 上它运行得很好!

It wasn't a problem due to Safari, but yes to the fact that I was using a Virtual Box with OS X. With a real macOS it worked great!

但是,请确保您拥有有效的证书,因为这仍然是必需的.

Yet, make sure you have an valid certificate, because that is still required.

这篇关于Javascript Safari 推送通知“允许"但总是放在“拒绝"中模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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