From 13b7bd8b2788dfe7e2b8aec723ca4382567c1b84 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Fri, 29 Apr 2016 13:54:01 +0100 Subject: [PATCH] Apple Push notifications. Trying something else. again --- app.js | 2 +- app/js/appv2.js | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 24826eb..16b4c30 100644 --- a/app.js +++ b/app.js @@ -222,7 +222,7 @@ app.post('/api/v1/register/ios', function(req, res) { registrationId = body['registrationId']; logger.debug(registrationId); - cal.registeriOSToken(id); + cal.registeriOSToken(registrationId); /* if (iosTokens.indexOf(registrationId) === -1) { iosTokens.push(registrationId); diff --git a/app/js/appv2.js b/app/js/appv2.js index f02867c..6b91d28 100644 --- a/app/js/appv2.js +++ b/app/js/appv2.js @@ -347,11 +347,24 @@ var SOController = (function() { // module.init = function() { + console.log('-=# A #=-'); attachClicks(); + console.log('-=# B #=-'); clock(); + console.log('-=# C #=-'); weatherClock(); + console.log('-=# D #=-'); soWebSocket = new SOWEBSOCKET(this); - setupPush(); + console.log('-=# E #=-'); + // Setup iOS notifications + console.log('device.platform', device.platform); + + console.log('-=# F #=-'); + if (device.platform === 'iOS' || device.platform === 'ios') { + console.log('-=# F.2 #=-'); + setupPushNotifications(); + } + console.log('-=# G #=-'); }; module.updateCalendar = function(data) { @@ -366,8 +379,6 @@ var SOController = (function() { if (window.cordova && !(window.cordova instanceof HTMLElement)) { if (device.platform === 'android' || device.platform === 'Android') { cordovaNotify(d); - } else if (device.platform === 'iOS' || device.platform === 'ios') { - setupPushNotifications(); } } else { browserNotify(d); @@ -382,11 +393,17 @@ function onDeviceReady() { SOController.init(); } -;(function() { + +if (window.cordova && !(window.cordova instanceof HTMLElement)) { + document.addEventListener('deviceready', onDeviceReady, false); + } + + +/*;(function() { if (window.cordova && !(window.cordova instanceof HTMLElement)) { document.addEventListener('deviceready', onDeviceReady, false); } else { onDeviceReady(); Notification.requestPermission(); } -})(); +})();*/