I'm having trouble getting the payload right for sending Firebase Cloud Messaging (FCM) notifications with click_action
.
According to .messaging.messaging.md#messagingsendeach, sendToDevice()
is not supported anymore? So I am trying to use sendEach()
.
Previously, I was able to do this:
const tokens = [
'token',
];
const payload = {
notification: {
title: 'Title',
body: 'Body',
icon: '.png',
click_action: '',
},
}
await admin.messaging().sendToDevice(tokens, payload);
Now I am trying this:
const messages = [
token: 'token',
notification: {
title: 'Title',
body: 'Body',
icon: '.png',
click_action: '',
},
];
await admin.messaging().sendEach(messages);
Which gives me this error:
> errorInfo: {
> code: 'messaging/invalid-argument',
> message: `Invalid JSON payload received. Unknown name "icon" at 'message.notification': Cannot find field.\n` +
> `Invalid JSON payload received. Unknown name "click_action" at 'message.notification': Cannot find field.`
> },
I see on .messaging.notification.md#notification_interface that icon
should be imageUrl
but there is no mention of click_action
anymore.
How do I send a notification with click_action
like I used to? Is there a different method that I am not seeing?