0

I am developing post and comment app, where one user can post some question, and any other use can answer on that post. but when any user comments on a post a user who post the question should receive notification. Suppose User (A) posted some question and User (B) answer on that. then user A should notify that somebody answers on your post and after clicking on a notification a particular post should open. Help me to sort the problem thankyou in advance :)

Nabeel Nazir
  • 420
  • 5
  • 15
  • Best option for you will be to cloud functions with a database trigger. With this, whenever someone replies to a post, you can use the admin api to send a notification to the related user which you can easily get using the same admin api. – Kushan Oct 30 '17 at 09:50

1 Answers1

1

Did you try to read documentation?

All you need is to send POST request to

https://fcm.googleapis.com/v1/projects/myproject-b5ae1/messages:send HTTP/1.1

With message

Content-Type: application/json
Authorization: Bearer ya29.ElqKBGN2Ri_Uz...HnS_uNreA

{
  "message":{
    "token" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
    "notification" : {
      "body" : "This is an FCM notification message!",
      "title" : "FCM Message",
      }
   }
}

For sending message to exact user you can create new unique topic or write correct to parameter. For example:

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA

{ "data": {
    "score": "5x1",
    "time": "15:10"
  },
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1..."
}
Andrey Danilov
  • 6,194
  • 5
  • 32
  • 56