From 2b2a88f67c2ba94dd419025e1dd077df5e898704 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Mon, 24 Feb 2020 10:03:23 -0500 Subject: #903 init push before sockets are set up if ES is on, other tweaks --- config.xml | 1 + package.json | 3 ++- www/js/EventServer.js | 27 +++++++++++++++++++++------ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/config.xml b/config.xml index 7065697e..105bea09 100644 --- a/config.xml +++ b/config.xml @@ -179,6 +179,7 @@ + diff --git a/package.json b/package.json index 739c68dc..aa5502fd 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,8 @@ }, "cordova-plugin-ionic-webview": { "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" - } + }, + "cordova-plugin-media-pp-fork": {} } }, "dependencies": { diff --git a/www/js/EventServer.js b/www/js/EventServer.js index ad5f673a..71718988 100644 --- a/www/js/EventServer.js +++ b/www/js/EventServer.js @@ -276,6 +276,13 @@ angular.module('zmApp.controllers') function setupMobileSocket() { + if (!pushInited) { + NVR.debug ("Calling pushInit()"); + pushInit(); + } else { + NVR.debug ("pushInit() already done"); + } + var loginData = NVR.getLogin(); var d = $q.defer(); @@ -300,10 +307,6 @@ angular.module('zmApp.controllers') // console.log("Connected to WebSocket with id: " + success.webSocketId); nativeWebSocketId = success.webSocketId; handleOpen(success); - if (!pushInited) { - NVR.debug("EventSever: Initializing FCM push"); - pushInit(); - } d.resolve(true); return d.promise; }, @@ -556,7 +559,7 @@ angular.module('zmApp.controllers') // "senderID": zm.gcmSenderId, "icon": "ic_stat_notification", sound: "true", - vibrate: ld.vibrateOnPush + vibrate: "true", //"sound": android_media_file } } @@ -565,8 +568,20 @@ angular.module('zmApp.controllers') } + PushNotification.hasPermission(function (succ) { + NVR.debug ("Push permission returned: "+JSON.stringify(succ)); + }, function (err) { + NVR.debug ("Push permission error returned: "+JSON.stringify(err)); + }); // console.log("*********** MEDIA BLOG IS " + mediasrc); - media = $cordovaMedia.newMedia(mediasrc); + + try { + media = $cordovaMedia.newMedia(mediasrc); + } + catch (err) { + NVR.debug ("Media init error:"+JSON.stringify(err)); + } + push.on('registration', function (data) { -- cgit v1.2.3