简而言之,我想使用 Google Cloud Functions 向订阅主题组合的设备发送通知。
\n\n文档说:
\n\n\n\n\n“主题中的\'TopicA\' &&(主题中的\'TopicB\' || 主题中的\'TopicC\')”
\n
我试图做的是:
\n\nvar 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 });\nRun 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