From 4f41e9e1b5bb52dbd9821f4847a63e3d040a59db Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Tue, 17 Jan 2017 13:14:40 +0100 Subject: [PATCH] Adding ability to (un/)subscribe to topics at firebase #262 - doc --- docs/MESSAGING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/MESSAGING.md b/docs/MESSAGING.md index b7a3dcbf..ba22ca75 100644 --- a/docs/MESSAGING.md +++ b/docs/MESSAGING.md @@ -102,6 +102,21 @@ Similarly to the message callback you can either wire this through `init` or as ); ``` +### Send messages to Topics +Based on the publish/subscribe model, FCM topic messaging allows you to send a message to multiple devices that have opted in to a particular topic. You compose topic messages as needed, and FCM handles routing and delivering the message reliably to the right devices. + +Client apps can subscribe to any existing topic, or they can create a new topic. When a client app subscribes to a new topic name (one that does not already exist for your Firebase project), a new topic of that name is created in FCM and any client can subsequently subscribe to it. + +```js + firebase.subscribeToTopic("news"); +``` + +and: + +```js + firebase.unsubscribeFromTopic("news"); +``` + ## Testing Using the Firebase Console gives you most flexibility, but you can quickly and easily test from the command line as well: