I'm using FCM
to send notifications for a project in booth plattforms, iOS
and Android
. Following are the payloads
I'm sending:
{
"to":"user_key",
"priority":"high",
"content_available":true,
"mutable_content":true,
"data":{
"body":"test"
}
}
After reading the Firebase
documentation, the behaviour when sending notification
and data payload
through FCM
is:
iOS
notification
-> body
is not defined.Android
data payload
only, it will receive data when is in background
.notification_payload
, system tray
will handle it.The thing is:
For Android
I want to avoid to pass notification_payload
in order to receive data when app is in background (in this way onMessageReceived() will be called). But then, I won´t receive notifications
in iOS
.
Help/Suggestions appreciated.
Server should use different json structures for IOS and Android push request. For example:
Android:
[data] => Array
(
[title] => Test
[message] => Message
)
IOS:
[notification] => Array
(
[title] => Title
[body] => Body
[sound] => 1
[vibrate] => 1
)
[data] => Array
(
[custom_key] => custom_value
)
You can edit it according to your task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With