├ 09

fcm topics

FCM supports server-side topic broadcasting. Instead of sending to a specific device token, you can send to all devices subscribed to a topic. edgepush passes the topic or condition straight through to the FCM HTTP v1 API.

Topic send

Devices subscribe to topics client-side via the Firebase SDK. Your server sends to the topic name (no "/topics/" prefix):

// all devices subscribed to "breaking-news" get this
await client.send({
  topic: "breaking-news",
  title: "Earthquake in Tokyo",
  body: "Magnitude 6.2, no tsunami warning",
});

Condition send

Target devices subscribed to a boolean combination of topics:

// devices subscribed to "sports" AND ("news" OR "breaking")
await client.send({
  condition: "'sports' in topics && ('news' in topics || 'breaking' in topics)",
  title: "Match started",
  body: "Team A vs Team B, kickoff now",
});

─  notes

  • Topic and condition sends are FCM-only. APNs does not have server-side topic broadcasting.
  • Exactly one of to, topic, or condition must be set per message. The API rejects requests with more than one.
  • A topic send consumes 1 event from your monthly quota regardless of how many devices are subscribed. FCM fans out on their side.
  • Devices subscribe to topics via FirebaseMessaging.getInstance().subscribeToTopic("news") on Android or Messaging.messaging().subscribe(toTopic:) on iOS (through the Firebase SDK, not edgepush).
  • The CLI supports --topic and --condition flags: edgepush send --topic news --title "Hello"