3
votes

I'm trying to use Safari Push Notifications with Windows Azure as backend. I was able to upload Website Push ID: web.com... certificate to Azure Mobile Services and it was accepted without any error message in the apple push notification settings.

To handle the Web Service Endpoints (webServiceURL/version/pushPackages/websitePushID, webServiceURL/version/devices/deviceToken/registrations/websitePushID, and so on) I created in the Mobile Services a API which is all working fine.

But I'm unable to send a push notification or get an error message.

My test code looks like this:

function send(req, res) {
    var push = req.service.push;
    var devicesTable = req.service.tables.getTable('devices');
    devicesTable.read({
        success: function(devices) {
            devices.forEach(function(device) {

                console.log("send to deviceToken " + device.deviceToken);

                push.apns.send(device.deviceToken, {
                    alert: 'Toast: A new Mobile Services task.',
                    payload: {
                        inAppMessage: "Hey, a new item arrived: '"
                    }
                });

                push.apns.send(device.deviceToken, {
                        alert: {
                            "title": "Test 123 ",
                            "body": "Test 123 ",
                            "action": "View"
                        },
                        "url-args": ["boarding"]
                    },
                    {
                        error : function(err) {
                            console.log("send error " + err);
                        }
                    }
                );

            });
        }
    });

    res.send(200, "");
}

Is my problem the formatting of the dictionary or does Azure Mobile Services for some reason not support Safari Push Notification?

As far as I know the APNS is the same for iOS, Mac and Safari push notifications.

Update: I tested it with SimplePush so the certificate is fine as is the registration of Safari. My payload looks like this:

// Create the payload body
$body['aps'] = array(
    'alert' => array(
        'title' => 'test',
        'body' => $message
    ),
    'url-args'  => array('test'),
);
1
I notice that your first push.apns.send doesn't have a error handler - maybe add one there to see if you're getting anything back. Also see if you get anything specific back by using apns.getFeedback(). See examples on this page: msdn.microsoft.com/en-us/library/windowsazure/jj839711.aspxSimon W
I tried both, no error message at all.catlan
Simplify the message format you're sending to see if it's something in the message that is causing non-delivery. Is your device token valid as held in the table? They can change through OS upgrades as well.Simon W
The device token is valid, as I wrote it works with SimplePush. I also tested with the most simplified message format possible: title and body are required. url-args are required as well when there is a placeholder(s) used in urlFormatString.catlan

1 Answers

0
votes

I assume that you've correctly registered your Safari client as per the guidance from Apple - have you tested your client using on a non-Azure implementation? Looking at the implementation guide from Apple there seems to be a lot of moving pieces even when not considering Azure as your push info source.