1
votes

I have some project that works with GCM to send web push (https://curiosity-driven.org/push-notifications), using tokens/endpoints that were collected from the browsers/users.

function subscribe() {
    return serviceWorker.ready.then(function(registration) {
        return registration.pushManager.subscribe({
            userVisibleOnly: true
        });
    }).then(function(subscription) {
        return subscription.endpoint; //Stored in DB
    });
}

But in Firebase we also need some p256dh and auth keys to send notifications. Is there any way to get these keys from existing(old) GCM tokens/endpoints?

1

1 Answers

1
votes

In Firebase we also need some p256dh and auth keys to send notifications

That's not true. You only need those keys to send a payload with the notification (otherwise you can just send a signal and then fetch the notifications from the server). You are probably confusing those key for the payload with the VAPID keys.

Is there any way to get these keys from existing(old) GCM tokens/endpoints?

No. You need to read the subscription again from the client with Javascript.