I've created two Firebase functions - one is an HTTPS where I am publishing a message to a topic, and a pub/sub function where I am responding to messages published to that topic.
testPubSub.ts
import { pubsub } from "firebase-functions";
export const testPubSub = pubsub
.topic("high-scores")
.onPublish(async (message, context) => {
console.log("hit test pubsub");
return null;
});
testHttps.ts
import { https } from "firebase-functions";
import { messaging } from "firebase-admin";
export const testHookEndpoint = https.onRequest(async (request, response) => {
const payload = {
notification: {
title: "Test title",
body: "test body"
}
};
const pubsubResponse = await messaging().sendToTopic("high-scores", payload);
console.log("response from pubsub", pubsubResponse);
response.send("success");
});
The HTTPS function appears to be running fine (200 response) and messaging is returning a message ID in the response, however I am not seeing the pub/sub function run in the Firebase Console.
When I look at GCP Console I see that "high-scores" has registered as a topic in the Pub/Sub tab, and I'm able to trigger other pub/sub functions in the project through Google Cloud Scheduler.
I'm not sure what step I'm missing for this.