If I subscribe to Web Push using a VAPID public key, it will look like this:
navigator.serviceWorker.register('/service-worker.js').then((sw) => {
sw.pushManager
.subscribe({
userVisibleOnly: true,
applicationServerKey: urlB64ToUint8Array(vapidPublicKey),
})
.then((subscription) => {
console.log(subscription); // This will log fcm endpoint!
});
});
Then I'll retrieve this payload.
{
"endpoint": "https://fcm.googleapis.com/fcm/send/...", // confusing part
"expirationTime": null,
"keys": {
"p256dh": "...",
"auth": "..."
}
}
Why is it that the endpoint is fcm?
Even more confusing for me is the fact that I can start delivering push notifications for this subscription object right inside my backend code, and it will work!
I did not create any firebase accounts or projects, nor did I pay any fees to firebase.
What is causing this?
Can I use web push in production without having to pay Firebase?
The Push API / Web Push is a browser standard. That's why.
Google Chrome uses Firebase to implement the Push API, under the hood, but you don't need to deal with proprietary Firebase features in order to use the Push API.
Each browser uses a different service, but the Push API offers a standard interface to web developers.