How to specify Android notification channel for FCM push messages in Android 8
Look at docs: https://firebase.google.com/docs/cloud-messaging/http-server-ref
android_channel_id The notification's channel id (new in Android O).
The app must create a channel with this ID before any notification with this key is received.
If you don't send this key in the request, or if the channel id provided has not yet been created by your app, FCM uses the channel id specified in your app manifest.
Try to include android_channel_id
in json you are about to post to fcm. I have no idea why manifest value is not working for you. Try to just add channel to your request, you should get the same effect as from Firebase Console.
Edit: I just realized you are asking for Amazon client integration. Maybe you are able to build json request manually then (I don't know much about Amazon services, sorry).
Depend on this resource : https://firebase.google.com/docs/cloud-messaging/http-server-ref
Here Payload look like :
{
"to":"$device_token"
"notification":{
"title":"Title",
"body":"Here Body",
"android_channel_id":"$channel_id", // For Android >= 8
"channel_id":"$channel_id", // For Android Version < 8
"image": "https://xxxxx.com/xxxxx.jpeg"
},
"data":{},
"priority":"normal"
}
FCM has migrated to HTTP v1 API:
https://fcm.googleapis.com/v1/projects/{{projectId}}/messages:send
android_channel_id
will cause bad request:
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "message.notification",
"description": "Invalid JSON payload received. Unknown name \"android_channel_id\" at 'message.notification': Cannot find field."
}
The correct payload should be:
{
"message": {
"token": "{{deviceToken}}",
"notification": {
"body": "This is an FCM notification message hello 23",
"title": "FCM Message",
"image": "https://lumiere-a.akamaihd.net/v1/images/au_moviesshowcase_mulan_poster_r_2_54011055.jpeg?region=0,0,960,1420"
},
"android": {
"notification": {
"channel_id": "channel_id_1"
}
},
"data": {
"key1": "42",
"key2": "sent by 21"
}
}
}
see https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#resource:-message