gpt4 book ai didi

Firebase FCM content_available 通过 Firebase Cloud Functions 引发错误

转载 作者:行者123 更新时间:2023-12-01 09:48:22 25 4
gpt4 key购买 nike

我一直在尝试通过 Cloud Functions 发送推送通知。这是有关如何从 Firebase 执行此操作的指南: https://github.com/firebase/functions-samples/blob/master/fcm-notifications/functions/index.js

这是我的有效载荷

const payload = {
"notification": {
title: 'Title!',
body: 'Body!',
sound: 'default'
},
"data":{"score":"3x1"},
"content_available": true,
};

现在,这引发了一个错误,当我检查日志时,这是错误:

Error: Messaging payload contains an invalid "content_available" property. Valid properties are "data" and "notification".
at FirebaseMessagingError.Error (native)
at FirebaseMessagingError.FirebaseError [as constructor] (/user_code/node_modules/firebase-admin/lib/utils/error.js:25:28)
at new FirebaseMessagingError (/user_code/node_modules/firebase-admin/lib/utils/error.js:130:23)
at /user_code/node_modules/firebase-admin/lib/messaging/messaging.js:465:23
at Array.forEach (native)
at Messaging.validateMessagingPayload (/user_code/node_modules/firebase-admin/lib/messaging/messaging.js:462:21)
at /user_code/node_modules/firebase-admin/lib/messaging/messaging.js:204:37
at process._tickDomainCallback (internal/process/next_tick.js:129:7)

如果我删除 content_available: true,它可以正常工作,所以我知道代码可以正常工作。

我还尝试使用 CURL/POST 请求 WITH content_available: true 手动发送它,它也有效。

谢谢!

最佳答案

contentAvailablesendToDevice(regToken, payload, options)options 参数中传递.示例代码位于 this documentation . MessagingOptions is here 的文档.

关于Firebase FCM content_available 通过 Firebase Cloud Functions 引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43827677/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com