0

I have an PWA app made without frameworks. I'm trying to implement the FCM to send notifications (also when the app is in background - service workes) to all devices that allowed it, but i only managed to send it to devices that i know the access tokens, i didn't figured out how to subscribe devices to topics... I need to create the topics on firebase console? Or i just need to subscribe devices to them? How could i do this in a secure way?

Found this answer here on stack overflow, but i still have doubts.

How to subscribe to topics with web browser using Firebase Cloud Messaging

xbennY
  • 1
  • Topics are automatically created when a user subscribes to them. For web clients you do that by calling the REST API as I answered in the question you linked, which you do from a server since it requires specifying the FCM server key. I updated my linked answer to be a bit clearer. – Frank van Puffelen Apr 03 '20 at 14:39
  • Thanks Frank! I did another API on my server that handles the subscriptions, now everything seems to be working. – xbennY Apr 03 '20 at 17:04
  • should i subscribe to a topic every time my PWA loads? to guarantee that the user will receive the notification – xbennY Apr 03 '20 at 23:50
  • Nope, you only need to subscribe each token once. But you will need to resubscribe when the token changed, somethint that the mobile SDKs handle behind the scenes I think. – Frank van Puffelen Apr 04 '20 at 00:14

0 Answers0