diff --git a/meshcentral-config-schema.json b/meshcentral-config-schema.json index b5f5d7a9..87801fb7 100644 --- a/meshcentral-config-schema.json +++ b/meshcentral-config-schema.json @@ -65,6 +65,15 @@ "npmPath": { "type": "string" }, "npmProxy": { "type": "string", "format": "uri" }, "allowHighQualityDesktop": { "type": "boolean", "default": true }, + "webPush": { + "type": "object", + "description": "When set with a valid email address, enables the MeshCentral web push notification feature. Allows administrators to send browser notifications to users even if they are not looking at the MeshCentral web site.", + "additionalProperties": false, + "properties": { + "email": { "type": "string", "description": "Server administrator email given to the FireFox and Chrome push notification services." } + }, + "required": [ "email" ] + }, "publicPushNotifications": { "type": "boolean", "default": false, "description": "When true, this server uses MeshCentral.com a push notification relay for Android notifications. Push notifications work even if the Android app is not open." }, "desktopMultiplex": { "type": "boolean", "default": false, "description": "When true, enabled a server modules that efficiently splits a remote desktop stream to multiple browsers. Also allows slow browsers to not slow down the session for fast ones, this comes at the cost of extra server memory and processing for all remote desktop sessions." }, "userAllowedIP": { "type": [ "string", "array" ] }, diff --git a/public/serviceworker.js b/public/serviceworker.js index 39c860ba..8a46e713 100644 --- a/public/serviceworker.js +++ b/public/serviceworker.js @@ -2,12 +2,12 @@ self.addEventListener('push', function (event) { if (event.data == null) return; var json = event.data.json(); - const options = { body: json.body, icon: '/favicon-303x303.png', tag: json.url }; + const options = { body: json.body, icon: '/favicon-303x303.png', data: { url: json.url } }; if (json.icon) { options.icon = '/images/notify/icons128-' + json.icon + '.png'; } - self.registration.showNotification(json.title, options); + event.waitUntil(self.registration.showNotification(json.title, options)); }); self.addEventListener('notificationclick', function (event) { event.notification.close(); - if ((event.notification.tag != null) && (event.notification.tag != '')) { event.waitUntil(self.clients.openWindow(event.notification.tag)); } + if ((event.notification.data.url != null) && (event.notification.data.url != '')) { event.waitUntil(self.clients.openWindow(event.notification.data.url)); } }); \ No newline at end of file diff --git a/sample-config-advanced.json b/sample-config-advanced.json index fb6843b0..15fb8bd4 100644 --- a/sample-config-advanced.json +++ b/sample-config-advanced.json @@ -51,6 +51,7 @@ "_npmPath": "c:\\npm.exe", "_npmProxy": "http://1.2.3.4:80", "_allowHighQualityDesktop": true, + "_webPush": { "email": "xxxxx@xxxxx.com" }, "_publicPushNotifications": true, "_desktopMultiplex": true, "_userAllowedIP": "127.0.0.1,192.168.1.0/24",