+
+
+
+ {{ $t("Webpush Helptext") }}
+
+
+
+
diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js
index c46690a0d..9bc4f050d 100644
--- a/src/components/notifications/index.js
+++ b/src/components/notifications/index.js
@@ -80,6 +80,7 @@ import Brevo from "./Brevo.vue";
import YZJ from "./YZJ.vue";
import SMSPlanet from "./SMSPlanet.vue";
import SMSIR from "./SMSIR.vue";
+import Webpush from "./Webpush.vue";
/**
* Manage all notification form.
@@ -168,6 +169,7 @@ const NotificationFormList = {
"Brevo": Brevo,
"YZJ": YZJ,
"SMSPlanet": SMSPlanet,
+ "Webpush": Webpush,
};
export default NotificationFormList;
diff --git a/src/lang/en.json b/src/lang/en.json
index d5b6961aa..da911cd29 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -1191,5 +1191,10 @@
"Maximum Retries": "Maximum Retries",
"Template ID": "Template ID",
"wayToGetClickSMSIRTemplateID": "Your template must contain an {uptkumaalert} field. You can create a new template {here}.",
- "Recipient Numbers": "Recipient Numbers"
+ "Recipient Numbers": "Recipient Numbers",
+ "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 000000000..c31649c41
--- /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);
+ }
+ }
+});