Firebase cloud message (FCM) is very easy to use. You can send messages on firebase console. but if you want to send rich messages, you cannot them in firebase console. You need to use firebase message api. and You must send rich messages to each platforms (iOS, android) because json structures are different each other.
- Android & iOS common part
Method: POST
Headers:
Content-Type: application/json
Authorization: key={your key }
- Android (body)
- If title,body element are in outside of data node. app cannot receive messages in background state.
{
"to" : "/topics/subject_android",
"data": {
"title": “Your title",
"body": “Your messages",
"image": “https://image full urls "
}
}
"to" : "/topics/subject_android",
"data": {
"title": “Your title",
"body": “Your messages",
"image": “https://image full urls "
}
}
- iOS
- title, body can be in notification-node , data-node contains image urls. you must add ‘mutable_content’ node. This node will be converted to ‘mutable-content’ in app and call ios push extention-component. ( You can show image in push. You need more codings)
{
"to" : "/topics/subject_ios",
"content_available": true,
"mutable_content": true,
"priority": "high",
"notification": {
"title": “Your title",
"body": “Your messages",
"badge": 1,
"sound": "cheering.caf"
},
"data": {
"data": {
"image": “https://image full urls "
}
}