【发布时间】:2019-08-18 06:04:48
【问题描述】:
我正在尝试使用适用于 node.js 的 firebase 管理 SDK(版本 7.0.0)让我的 FCM 网络通知包含指向我的网站的可点击链接。据我所知,我正在关注文档到 T,但我无法使链接正常工作。澄清一下,否则我的通知工作正常,只是我没有工作的链接。
documentation 声明:
对于从应用服务器发送的通知消息,FCM JavaScript API 支持 fcm_options.link 键。通常这被设置为您的网络应用程序中的一个页面
我已将webpush.fcm_options.link 包含在我的通知消息中。我确保在我的消息中包含明确的notification 有效负载,因为文档指出data 消息不支持fcm_options.link。
这是我当前消息的结构:
{
notification: {
title: 'Title',
body: 'Body',
},
data: {
// my data here
},
webpush: {
notification: {
requireInteraction: true,
icon: '/icons/notification.png'
},
fcm_options: {
link: 'https://example.com/'
}
},
// android: {},
// apns: {},
topic: 'sometopic'
};
这是我用来发送消息的函数:
const admin = require('firebase-admin')
const sendMessage = message => {
admin
.messaging()
.send(message)
.then(response => {
console.log(response)
})
.catch(error => {
console.log(error)
});
};
link 属性应该根据文档工作:我的 url 包含 https 并且我的通知是从应用服务器发送的,并且包含显式通知负载。目前,点击通知只是让它消失,没有其他任何事情发生。
【问题讨论】:
-
您能否更新您的问题以包含您用于发送消息的 Admin SDK 功能?
-
@JenPerson 已编辑,谢谢!
-
嗯......这看起来都是正确的。我想确保您使用的是新的 FCM API,并且看起来您正在使用。您使用的是哪个版本的管理员?在此期间,我会尝试从团队中了解更多信息
-
@JenPerson 几天前使用
7.1.1,是的,我正在使用 v1 api。非常感谢您的帮助! -
能否告诉您您使用的是哪个版本的 Firebase 客户端 SDK?
标签: node.js firebase push-notification firebase-cloud-messaging