Masahiro Aoki
Masahiro Aoki

Reputation: 875

Why do I need to use admin SDK with Cloud Functions to send notifications to other device using FCM in Flutter?

Im new to Flutter. I wondered why I need to use Cloud Functions to send notifications to the other device in Flutter. If one device simply know the token of the partner device, I think that it can specify the token and send a notification directly from the client side. Does this question relate to this answer? How to send push Notification using FCM and Flutter(One to Another Device)? Thank you.

Upvotes: 0

Views: 104

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317402

You certainly could send the message directly from your client app, but you would then have a huge security problem. The Admin SDK requires a service account to initialize, and you would have to package that service account in your app so it could call the FCM API.

Distributing your service account is strongly discouraged, as it now allows everyone to do everything to your project that the service account is allowed to do. This could be anything and everything.

Instead, people put messaging code on secure backends where the service account can't be seen by others. Cloud Functions is a popular option for this, but you can use whatever backend you want.

Upvotes: 3

Related Questions