web-manager 4.0.13 → 4.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -1
- package/dist/modules/notifications.js +12 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -6,8 +6,8 @@ class Notifications {
|
|
6
6
|
|
7
7
|
// Check if notifications are supported
|
8
8
|
isSupported() {
|
9
|
-
return 'Notification' in window &&
|
10
|
-
'serviceWorker' in navigator &&
|
9
|
+
return 'Notification' in window &&
|
10
|
+
'serviceWorker' in navigator &&
|
11
11
|
this.manager.firebaseMessaging !== undefined;
|
12
12
|
}
|
13
13
|
|
@@ -79,7 +79,7 @@ class Notifications {
|
|
79
79
|
storage.set('notifications', {
|
80
80
|
subscribed: true,
|
81
81
|
token: token,
|
82
|
-
|
82
|
+
timestamp: new Date().toISOString(),
|
83
83
|
uid: this.manager.auth().getUser()?.uid || null
|
84
84
|
});
|
85
85
|
|
@@ -102,7 +102,7 @@ class Notifications {
|
|
102
102
|
|
103
103
|
const { deleteToken } = await import('firebase/messaging');
|
104
104
|
const messaging = this.manager.firebaseMessaging;
|
105
|
-
|
105
|
+
|
106
106
|
if (messaging) {
|
107
107
|
await deleteToken(messaging);
|
108
108
|
}
|
@@ -147,7 +147,7 @@ class Notifications {
|
|
147
147
|
|
148
148
|
const { getToken } = await import('firebase/messaging');
|
149
149
|
const swRegistration = this.manager.state.serviceWorker;
|
150
|
-
|
150
|
+
|
151
151
|
return await getToken(messaging, {
|
152
152
|
serviceWorkerRegistration: swRegistration
|
153
153
|
});
|
@@ -166,7 +166,7 @@ class Notifications {
|
|
166
166
|
|
167
167
|
const { onMessage } = await import('firebase/messaging');
|
168
168
|
const messaging = this.manager.firebaseMessaging;
|
169
|
-
|
169
|
+
|
170
170
|
if (!messaging) {
|
171
171
|
return () => {};
|
172
172
|
}
|
@@ -191,19 +191,19 @@ class Notifications {
|
|
191
191
|
|
192
192
|
const { onMessage } = await import('firebase/messaging');
|
193
193
|
const messaging = this.manager.firebaseMessaging;
|
194
|
-
|
194
|
+
|
195
195
|
if (!messaging) {
|
196
196
|
return () => {};
|
197
197
|
}
|
198
198
|
|
199
199
|
return onMessage(messaging, (payload) => {
|
200
200
|
console.log('Foreground message received:', payload);
|
201
|
-
|
201
|
+
|
202
202
|
// Show notification if app is in foreground
|
203
203
|
if (payload.notification) {
|
204
204
|
const { title, body, icon, badge, image } = payload.notification;
|
205
205
|
const clickAction = payload.data?.click_action || payload.notification.click_action;
|
206
|
-
|
206
|
+
|
207
207
|
const notification = new Notification(title, {
|
208
208
|
body,
|
209
209
|
icon,
|
@@ -235,13 +235,13 @@ class Notifications {
|
|
235
235
|
try {
|
236
236
|
const firestore = this.manager.firebaseFirestore;
|
237
237
|
const user = this.manager.auth().getUser();
|
238
|
-
|
238
|
+
|
239
239
|
if (!firestore || !token) {
|
240
240
|
return;
|
241
241
|
}
|
242
242
|
|
243
243
|
const { doc, setDoc, serverTimestamp } = await import('firebase/firestore');
|
244
|
-
|
244
|
+
|
245
245
|
const subscriptionData = {
|
246
246
|
token,
|
247
247
|
platform: 'web',
|
@@ -282,4 +282,4 @@ class Notifications {
|
|
282
282
|
}
|
283
283
|
}
|
284
284
|
|
285
|
-
export default Notifications;
|
285
|
+
export default Notifications;
|
package/package.json
CHANGED