Push notifications

This commit is contained in:
Martin Donnelly 2016-04-29 09:42:11 +01:00
parent 863bbe56d0
commit e329cf7122
2 changed files with 18 additions and 5 deletions

12
app.js
View File

@ -216,7 +216,17 @@ app.post('/api/v1/projector/on', projector_v1.turnon);
app.post('/api/v1/register/ios', function(req, res) {
console.log(req.body);
var body = req.body;
if (body.hasOwnProperty(id)) {
logger.debug(body.id);
if (iosTokens.indexOf(body.id) === -1) {
iosTokens.push(body.id);
logger.info('IOS Device registered.');
}
}
});

View File

@ -25,21 +25,24 @@ var SOController = (function() {
off: ['frontLightOff', 'backLightOff'], on: ['frontLightOn', 'backLightOn']
};
console.log('Localmode',local);
if (local) {
console.log('Using local urls');
path = 'http://localhost:3000/';
wsUrl = 'ws://localhost:3001';
} else {
console.log('Using remote urls');
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/';
}
MicroEvent.mixin(bus);
var iOS = ['iPad', 'iPhone', 'iPod'].indexOf(navigator.platform) >= 0;
if (iOS) {
$('#iosTaskbar').show();
path = 'http://localhost:3000/';
// path = 'http://localhost:3000/';
}
var module = {lights: lightsList};
@ -119,7 +122,7 @@ var SOController = (function() {
}
function turnOnLights(id) {
console.log(id);
console.log('turnonlights',path + 'api/v1/lighting/on');
$.post(path + 'api/v1/lighting/on', {light: id}, function() {});
}
@ -368,7 +371,7 @@ var SOController = (function() {
}
};
return module;
})();