0

I'm building a photo app where users can press like. Assume there is a user A and B. I need to show a notification when user A press like to user B. User B (app can be either in background or terminated) must get a push notification something like "Hey you got a like".

  1. is it a good idea to use fcm in this situation?

  2. if so how to accomplish these?

Referred links:

Restrict FCM Notification for a specific users in Flutter

https://firebase.flutter.dev/docs/messaging/usage

3

Naveen
  • 95
  • 3
  • 8
  • To send a message to a device, you need to call the FCM API and specify the so-called FCM server key. As its name implies this key should only be used on a server, or otherwise trusted environment, such as your development machine, or Cloud Functions. The reason for this is that with the server key someone can send any message they want to all of your users. For an example of how to do this, see https://stackoverflow.com/questions/37990140/how-to-send-one-to-one-message-using-firebase-messaging and https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html – Frank van Puffelen Mar 19 '21 at 14:43
  • While these are for Android, the exact same approach applies to Flutter apps. – Frank van Puffelen Mar 19 '21 at 14:43

1 Answers1

1

This is possible with firebase push notifications. But its not possible to trigger this from client-side. You could accomplish this with a cloud function...

Jannik
  • 635
  • 1
  • 6
  • 14
  • Yeah how about [REST](https://firebase.flutter.dev/docs/messaging/notifications#via-rest) ? – Naveen Mar 19 '21 at 13:20
  • Do i need to store the fcm token id and user it later to send push notifications or any other way to make it simple ? @jannik – Naveen Mar 19 '21 at 13:22