小编MNa*_*sar的帖子

通过条件将 Firebase 云消息传递 (FCM) 发送到多个主题的正确语法是什么

简而言之,我想使用 Google Cloud Functions 向订阅主题组合的设备发送通知。

\n\n

文档说:

\n\n
\n

“主题中的\'TopicA\' &&(主题中的\'TopicB\' || 主题中的\'TopicC\')”

\n
\n\n

我试图做的是:

\n\n
var topicsConditions = `\'${type}\' in topics && (\'${area}\' in topics || \'${city}\' in topics)`;\n\n// Send a message to devices subscribed to the provided topic.\nadmin.messaging().sendToCondition(topicsConditions, notificationPayload)\n  .then(function(response) {\n    // See the MessagingTopicResponse reference documentation for the\n    // contents of response.\n    console.log("Successfully sent message:", response);\n  })\n  .catch(function(error) {\n    console.log("Error sending message:", error);\n  });\n
Run Code Online (Sandbox Code Playgroud)\n\n

但我不断收到此错误:

\n\n
\n

发送消息时出错:{ 错误:提供的参数无效。原始服务器响应:“无效的“条件”字段:仅支持\'主题\'条件\n”。状态代码:400。\n 位于 FirebaseMessagingError.Error(本机)\n 位于 FirebaseMessagingError.FirebaseError [作为构造函数] (/user_code/node_modules/firebase-admin/lib/utils/error.js:39:28)\n …

node.js firebase google-cloud-functions firebase-cloud-messaging

2
推荐指数
1
解决办法
2653
查看次数