根据react-native-fcm软件包,您可以在数据对象中为FCM消息传递有效负载包含自定义嵌套对象。FCM消息有效负载错误,数据对象内的嵌套对象错误输出
according to this post by the package author
像这样:
var payload = {
data: {
custom_notification: {
title: 'title',
body: 'body',
priority: 'high',
id: 'id',
group: 'group'
}
}
};
这是在所有的应用程序的状态,如果你只是一个通知有效载荷或数据载荷,这将不会发生接收抬头通知的目的。
当我实现这个在我的云功能,我得到以下错误:
Error: Messaging payload contains an invalid value for the "data.custom_notification" property. Values must be strings.
所以我在亏损为其他人如何成功地使用呢?
我不知道是否有一些问题,我的环境什么的,将其通过火力支持,给我的(并且是文档)下面的测试有效载荷事情出现了错误:
var payload = {
"to":"FCM_TOKEN",
"data": {
"type":"MEASURE_CHANGE",
"body": "test body",
"title": "test title",
"color":"#00ACD4",
"priority":"high",
"id": "id",
"show_in_foreground": true
}
};
我得到的以下错误:
Error sending message stringify: {"code":"messaging/invalid-payload","message":"Messaging payload contains an invalid \"to\" property. Valid properties are \"data\" and \"notification\"."}
在这里呆了几天,所以希望我能在这方面得到一些帮助。
在此先感谢!
尝试使用到字符串化的有效载荷: 体:JSON.stringify({ 您的JSON对象 }) –