web-manager 4.3.0 → 4.3.1
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.
|
@@ -5,6 +5,8 @@ class Notifications {
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
initialize(config) {
|
|
8
|
+
this._vapidKey = this.manager.config?.firebase?.messaging?.config?.vapidKey || null;
|
|
9
|
+
|
|
8
10
|
const storage = this.manager.storage();
|
|
9
11
|
const stored = storage.get('notifications');
|
|
10
12
|
const permission = typeof Notification !== 'undefined' ? Notification.permission : 'default';
|
|
@@ -112,10 +114,9 @@ class Notifications {
|
|
|
112
114
|
|
|
113
115
|
// Get FCM token
|
|
114
116
|
const { getToken } = await import('firebase/messaging');
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
117
|
+
const tokenOptions = { serviceWorkerRegistration: swRegistration };
|
|
118
|
+
if (this._vapidKey) { tokenOptions.vapidKey = this._vapidKey; }
|
|
119
|
+
const token = await getToken(messaging, tokenOptions);
|
|
119
120
|
|
|
120
121
|
if (!token) {
|
|
121
122
|
throw new Error('Failed to get FCM token');
|
|
@@ -198,9 +199,9 @@ class Notifications {
|
|
|
198
199
|
const { getToken } = await import('firebase/messaging');
|
|
199
200
|
const swRegistration = this.manager.state.serviceWorker;
|
|
200
201
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
const tokenOptions = { serviceWorkerRegistration: swRegistration };
|
|
203
|
+
if (this._vapidKey) { tokenOptions.vapidKey = this._vapidKey; }
|
|
204
|
+
return await getToken(messaging, tokenOptions);
|
|
204
205
|
} catch (error) {
|
|
205
206
|
console.error('Get token error:', error);
|
|
206
207
|
return null;
|
package/package.json
CHANGED