Brief implementation of Firebase Cloud Messaging (FCM) for both client and server, showcasing essential setup and configuration steps.
1- Make sure to have the following:
- Service Account
- VAPID
- FCM project & app Credentials
2- Replace app/server/service-account.json
with your own
3- Replace app/client/firebase-config.json
with your own
4- Replace app/client/manifest.json[gcm_sender_id]
with your FCM Sender ID
5- Run the following:
$ docker compose up -d
# Server listening on port 3000
$ docker exec -t fcm-server yarn run dev
1- Open http://localhost to ensure the client app is working properly.
2- Ensure that Notification permission is allowed and sw.js is successfully registered in the browser.
3- Send a sample notification:
# Login to the server's container & Send a notification by:
$ docker exec -t fcm-server node cli.js notif
# You can see the usage by:
$ node cli.js notif --help