We are using FCM to send remote notifications for both iOS and Android. The following are the payloads we are sending from the backend.
options = {
notification: {
title: "title",
body: body,
sound: 'default'
},
priority: "high",
content_available: true,
data: {
type: 'type',
id: id,
}
}
This works for ios and android.
But for some reason, the android side we need to send title
,body
and sound
for keys in data
payload and need to remove notification
payload.
Now the notifications are not receiving ios side when app is not active, banner notifications are not arriving but the data is receiving when app is active. We need banners on the iOS side.
Is that notification
key is mandatory to display banner
in iOS?
How to use the same payload for both iOS and Android.
options = {
priority: "high",
content_available: true,
data: {
title: "title",
body: body,
sound: 'default'
type: 'type',
id: id,
}
}
Also tried adding content_available
and priority
keys with various combinations.
Gone through all FCM docs and it still confuses. Help/Suggestions appreciated.
notification
payload.data
-only payloads (in your first scenario) are stored by FCM until your app goes on foreground and is connected to FCM. – AL."Android"
,"iOS"
). So that when you'll be sending messages, you'll first have to check the type of device. I did say it's more work, but it's a sure way to give you control over things. AFAIK, it is the developer's responsibility to keep track of the registration tokens and any details that should be associated with it. – AL.