I using FCM to send notification for Android and iOS apps via my php server.Just because the different payload need by different platform,now I facing a big problem.
Now my payload structure look like this
"registration_id":[all my firebase token here]
//***here just for iOS
"notification":{
"title":"Match update",
"body":"Arsenal goal in added time, score is now 3-0"
"sound" : "default"
"priority" : 'high'
"content_available" = true
}
//***here I need this for Android
"data":{
"title":"Match update",
"body":"Arsenal goal in added time, score is now 3-0"
"id": "my_id"
//other data I need in android
}
So by sending the payload I actually get the notification in iOS and Android at the same time.Which is good,but..
The real problem start here..
In android,I dont have my app scan for the notification
field,I want to handle my app when the notification arrive in Android device start from "data" field.Although I dont have get data in the "notification",the app seem automatically handle for me for the "notification" data.
But if I not include the "notification" field in the payload above,Android part is behave as what I want,but in iOS,I unable to get the notification at all.
After look at this Platform Override mention in this answer,I modify my payload like below:
"registration_id":[all my firebase token here]
"android":{
"data":{
"title":"Match update",
"body":"Arsenal goal in added time, score is now 3-0"
}
}
"apns":{
"payload":{
"aps":{
"alert":{
"title":"Hello",
"body":"Please confirm your availability"
}
"sound" : "default"
"priority" : 'high'
"content_available" = true
}
}
But with the payload structure above,both my Android and iOS cant receive any notification.
Note: Both my Android and iOS app can get notification from Firebase console.
So my question is : How to send different structure of payload to different platform to solve this kind of dilemma?