Apple Push notifications. Trying something else. again

This commit is contained in:
Martin Donnelly 2016-04-29 11:44:48 +01:00
parent 1e7740f9be
commit 1ea5285973
2 changed files with 7 additions and 6 deletions

5
app.js
View File

@ -268,11 +268,12 @@ app.post('/api/v1/register/ios', function(req, res) {
logger.info('Sending the same notification each of the devices with one call to pushNotification.'); logger.info('Sending the same notification each of the devices with one call to pushNotification.');
var note = new apn.notification(); var note = new apn.notification();
note.setAlertText('Hello, from node-apn!'); var now = new Date();
note.setAlertText('Hello, from node-apn!' + now.toISOString() );
note.setAlertTitle('Smart Office'); note.setAlertTitle('Smart Office');
note.setBadge(1); note.setBadge(1);
note.setSound('dong.aiff'); note.setSound('dong.aiff');
note.badge = 1; note.badge = 1;

View File

@ -36,7 +36,7 @@ var SOController = (function() {
wsUrl = 'ws://ec2-52-50-147-81.eu-west-1.compute.amazonaws.com:8080'; wsUrl = 'ws://ec2-52-50-147-81.eu-west-1.compute.amazonaws.com:8080';
path = 'http://ec2-52-50-147-81.eu-west-1.compute.amazonaws.com/'; path = 'http://ec2-52-50-147-81.eu-west-1.compute.amazonaws.com/';
} }
MicroEvent.mixin(bus); MicroEvent.mixin(bus);
var iOS = ['iPad', 'iPhone', 'iPod'].indexOf(navigator.platform) >= 0; var iOS = ['iPad', 'iPhone', 'iPod'].indexOf(navigator.platform) >= 0;
@ -329,16 +329,16 @@ var SOController = (function() {
var push = PushNotification.init({"android":{},"ios":iosConfig,"windows":{}}); var push = PushNotification.init({"android":{},"ios":iosConfig,"windows":{}});
push.on('registration', function(d) { push.on('registration', function(d) {
console.log('Registration: ', JSON.stringify(d)); console.log('*PUSH* Registration: ', JSON.stringify(d));
$.post(path + 'api/v1/register/ios', d, function() {}); $.post(path + 'api/v1/register/ios', d, function() {});
}); });
push.on('notification', function(d) { push.on('notification', function(d) {
console.log('Notification: ', d); console.log('*PUSH* Notification: ', JSON.stringify(d));
}); });
push.on('error', function(e) { push.on('error', function(e) {
console.error('Push error:', e); console.error('*PUSH* Push error:', e);
}); });
}; };