I've been tearing (what's left of) my hear out today now that I've gotten the certificate and everything configured correctly in my account (https://community.pushwoosh.com/questions/380/problem-creating-safari-website-notification-platform-configuration).

Now I'm trying to implement the actual code to allow permission to work with no luck.

When it runs, in Safari Version 7.0.3 (9537.75.14), watching the error console, I get first "This is a new web service URL and its validity is unknown." and then "The user said no." without any interaction. I've searched all over the Web and can't find anything helpful (there are things about testing locally, etc.).

I am fairly confident I have it configured correctly.

Looking for help again. Thanks in advance!

asked 04 Apr '14, 21:51
embarpub's gravatar image

embarpub
513

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.

permanent link
answered 08 Apr '14, 16:07
embarpub's gravatar image

embarpub
513

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×111
×16

question asked: 04 Apr '14, 21:51

question was seen: 1,753 times

last updated: 08 Apr '14, 16:07