+
+
+
+ {{ $t("Webpush Helptext") }}
+
+
+
+
diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js
index efa2af5c49..c59503ee9e 100644
--- a/src/components/notifications/index.js
+++ b/src/components/notifications/index.js
@@ -67,6 +67,7 @@ import Cellsynt from "./Cellsynt.vue";
import WPush from "./WPush.vue";
import SIGNL4 from "./SIGNL4.vue";
import SendGrid from "./SendGrid.vue";
+import Webpush from "./Webpush.vue";
/**
* Manage all notification form.
@@ -142,6 +143,7 @@ const NotificationFormList = {
"Cellsynt": Cellsynt,
"WPush": WPush,
"SendGrid": SendGrid,
+ "Webpush": Webpush,
};
export default NotificationFormList;
diff --git a/src/lang/en.json b/src/lang/en.json
index e215f1031f..ee87cc53c7 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -1051,5 +1051,10 @@
"RabbitMQ Password": "RabbitMQ Password",
"rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.",
"SendGrid API Key": "SendGrid API Key",
- "Separate multiple email addresses with commas": "Separate multiple email addresses with commas"
+ "Separate multiple email addresses with commas": "Separate multiple email addresses with commas",
+ "Notifications Enabled": "Notifications Enabled",
+ "Allow Notifications": "Allow Notifications",
+ "Browser not supported": "Browser not supported",
+ "Unable to get permission to notify": "Unable to get permission to notify (request either denied or ignored).",
+ "Webpush Helptext": "Web push only works with SSL (HTTPS) connections. For iOS devices, webpage must be added to homescreen beforehand."
}
diff --git a/src/serviceWorker.ts b/src/serviceWorker.ts
new file mode 100644
index 0000000000..c31649c412
--- /dev/null
+++ b/src/serviceWorker.ts
@@ -0,0 +1,23 @@
+// Needed per Vite PWA docs
+import { precacheAndRoute } from 'workbox-precaching'
+declare let self: ServiceWorkerGlobalScope
+precacheAndRoute(self.__WB_MANIFEST)
+
+// Receive push notifications
+self.addEventListener('push', function (event) {
+ if (self.Notification?.permission !== 'granted') {
+ console.error("Notifications aren't supported or permission not granted!");
+ return;
+ }
+
+ if (event.data) {
+ let message = event.data.json();
+ try {
+ self.registration.showNotification(message.title, {
+ body: message.body,
+ });
+ } catch (error) {
+ console.error('Failed to show notification:', error);
+ }
+ }
+});