4

I am using react-native-firebase in react-native project for Firebase cloud messaging. It is working fine when app is running or in background/minimised. But notification not received when app is killed or not opened after mobile restart. I am sending the following body to

https://fcm.googleapis.com/fcm/send

{ 
 "to": "/topics/chatProperty_P00025_14", 
 "notification" : {
 "body" : "great match!",
 "content_available" : true,
 "priority" : "high",
 "title" : "Portugal vs. Denmark",
   "sound":"default",
   "vibrate":true
 },
 "data" : {
 "body" : "14_P00025",
 "content_available" : true,
 "priority" : "high",
 "title" : "Portugal vs. Denmark",
 "type" : "propertyAdd",
   "sound":"default",
   "vibrate":true,
   "propertyId":"1"
 }
}
Syed Hassan
  • 438
  • 4
  • 19

1 Answers1

0
"to":"your token",
"apn": {
    "content_available": "1"
},
"content_available": true,
"sound": "default",
"icon": "ic_launcher",
"priority": "high",
"notification": {
    "title": "Reminder Appointment",
    "body": "You have appointment today with Doctor ${detailData.doctor_name} on ${appTime}"
},
"data": {
    "id_appointment": "${detailData.book_id}",
    "id_doctor": "${detailData.doctor_email}",
    "id_patient": "${detailData.patient_email}",
    "speciality": "${detailData.speciality}",
    "speciality_id": "${detailData.speciality_id}"
}

if you're using react native firebase , you can try using this format on postman or insomnia by hit this endpoint (https://fcm.googleapis.com/fcm/send), check the structure and don't forget include the firebase key (AlzaXXXXXX)

Hari Antara
  • 51
  • 1
  • 5