最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Send Firebase Cloud Messaging (FCM) notification with click_action - Stack Overflow

programmeradmin0浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论