permissionData.permission === 'denied' without interaction

Answered

Comments

1 comment

  • Avatar
    Frank Bravo

    Seems there were a few things going on.

    First, there is an error in the code on this page (http://www.pushwoosh.com/programming-push-notification/safari/safari-website-notifications/). The correct code is:

    // pushwoosh.com Safari push notifications
    var checkRemotePermission = function (permissionData) {
        if (permissionData.permission === 'default') {
            console.log('This is a new web service URL and its validity is unknown.');
            window.safari.pushNotification.requestPermission(
                'https://cp.pushwoosh.com/json/1.3/safari', // Pushwoosh web service endpoint URL, without slash
                'web.com.xxxxxxx.yyyyyyy', // Your unique reverse-domain Website Push ID from the Developer Center, starts with "web."
                { application:'xxxxx-xxxxx'},  // Your Pushwoosh application code from the Control Panel
                checkRemotePermission  // The callback function.
            );
        } else if (permissionData.permission === 'denied') {
            console.log('The user said no.');
        } else if (permissionData.permission === 'granted') {
            console.log('The web service URL is a valid push provider, and the user said yes.');
            // permissionData.deviceToken is now available to use.
        }
    };
    
    // Ensure that the user can receive Safari Push Notifications
    window.onload = function(){
        if ('safari' in window && 'pushNotification' in window.safari) {
            var permissionData = window.safari.pushNotification.permission('web.com.xxxxxx.yyyyyy'); // Your Website Push ID
            checkRemotePermission(permissionData);
        } else {
            console.log('Push Notifications are available for Safari browser only');
        }
    };
    

    Second, there was an issue with the Pushwoosh backend. They located a bug that resulted in Safari pushes not working properly during registration. The developers fixed the bug this morning, and everything worked.

Please sign in to leave a comment.