firebase - 使用 typrescript 和 if 语句的云函数
问题描述
您好,我是云功能的新手,我想问一下为什么在一个 if 语句中获得多个主题是我的云功能:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();
const fcm = admin.messaging();
export const sendToTopic = functions.firestore
.document("Doctor2019/{documentId}")
.onCreate(async snapshot => {
const payload: admin.messaging.MessagingPayload = {
notification: {
title: 'NEW POST!',
body: `Click here to see New Post`,
icon: 'your-icon-url',
click_action: 'FLUTTER_NOTIFICATION_CLICK'
}
};
return fcm.sendToTopic('Doctor2019', payload);
});
问题是我有不止一个主题我想做的是检查其他集合上文档的创建并基于此发送通知,我真的不知道该怎么做,有什么帮助吗?
解决方案
我看到您想将消息发送到 FCM 上与不同文档创建相关的不同主题。
您不能使用一个函数来实现这一点,因为该函数与特定集合上的文档创建相关联。您需要做的是为不同的集合创建不同的功能。
推荐阅读
- python - Discord.py bot,随机图片海报
- java - 无法使用 Gson 将 JSON 编组为复杂的 Java 类型
- service - 绑定服务的 Systemd 计时器重新启动它绑定到的服务
- python - Python-can 记录文件时间
- jquery-select2 - 我用了select2。但升级了 4.0.13。它出现了标题
- python - pip 安装在 usr/lib/python3.6/site-packages 而不是 ubuntu 服务器上的 virtualenv
- git - git reset 后 git unstagged 文件
- node.js - 从 Node REST API 获取数据并填充其他控件
- sql - 如何根据 MS-Access (Sql) 中的表单的映射表和值生成 ID 序列?
- java - 使用 Stream 将列表中的元素移动到第一个位置