Skip to content

Commit 272a020

Browse files
sarpdorukmarco-c
authored andcommitted
FCM endpoint support for GCM/FCM projects (#415)
1 parent 7fa4848 commit 272a020

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/web-push-lib.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ WebPushLib.prototype.generateRequestDetails = function(subscription, payload, op
219219
}
220220

221221
const isGCM = subscription.endpoint.indexOf('https://android.googleapis.com/gcm/send') === 0;
222+
const isFCM = subscription.endpoint.indexOf('https://fcm.googleapis.com/fcm/send') === 0;
222223
// VAPID isn't supported by GCM hence the if, else if.
223224
if (isGCM) {
224225
if (!currentGCMAPIKey) {
@@ -251,6 +252,8 @@ WebPushLib.prototype.generateRequestDetails = function(subscription, payload, op
251252
requestDetails.headers['Crypto-Key'] = vapidHeaders['Crypto-Key'];
252253
}
253254
}
255+
} else if (isFCM && currentGCMAPIKey) {
256+
requestDetails.headers.Authorization = 'key=' + currentGCMAPIKey;
254257
}
255258

256259
requestDetails.body = requestPayload;

0 commit comments

Comments
 (0)