Monday, 30 November 2020

Javascript Safari Push Notifications "Allowed" but are always put in "Deny" mode

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

enter image description here

Three problems now happen:

  1. After pressing "Allow" nothing is triggered, the console is empty and should print "Device Token: ..." in the granted condition.
  2. After quit and reopen Safari, I went to Safari > Preferences > Websites > Notifications and my website has the value "Deny"!
  3. If I change the value from "Deny" to "Allow" it's not saved. Safari will put back to "Deny"

enter image description here

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);

I have the routes:

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

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

The official documentation says the following:

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.

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

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



from Javascript Safari Push Notifications "Allowed" but are always put in "Deny" mode

No comments:

Post a Comment