title: Difference between "topic messages", "target messages", and "user segments" in Firebase Cloud Messaging
body: <p>I want to send push notifications using Firebase Cloud Messaging to users of my App. I have two categories:</p>
  
  <ol>
  <li>Country 1</li>
  <li>Country 2</li>
  </ol>
  
  <p>In the settings of the app, users have radio buttons to subscribe to either Country 1 or Country 2. I already completed the steps described at <a href="https://firebase.google.com/docs/cloud-messaging/android/client" rel="nofollow noreferrer">https://firebase.google.com/docs/cloud-messaging/android/client</a> and when I use <code>FirebaseInstanceId.getInstance().getToken()</code>, I am obtaining the device token successfully. I was able to send notifications to single devices by using the compose message section of the Firebase console. The Firebase console has three radio buttons:</p>
  
  <p>1) User segment
  2) Topic
  3) Single device</p>
  
  <p>I understand how to send messages to single devices by using the device token. Now I am trying to fully understand the difference between "topic messages", "target messages", and "user segments". I was reading at <a href="https://firebase.google.com/docs/cloud-messaging/android/topic-messaging" rel="nofollow noreferrer">https://firebase.google.com/docs/cloud-messaging/android/topic-messaging</a> the following information:</p>
  
  <blockquote>
    <p>Topic messages are optimized for throughput rather than latency. For fast, secure delivery to single devices or small groups of devices, target messages to registration tokens, not topics.</p>
  </blockquote>
  
  <p>For what I need, I think using "topic messages" would be convenient, where I would have two topics: "Country 1" and "Country 2", and users decide to subscribe to the country they want to receive promotions from in this case.</p>
  
  <p>"User segments" means that I take a group of device tokens and add them to a segment, and then I broadcast a push notification to that segment, correct? In the case of "topic messages", I would let users to subscribe to the country they want, and in my code I would have something such as the following lines to let someone subscribe to a specific country, correct?:</p>
  
  <pre><code>FirebaseMessaging.getInstance().subscribeToTopic("country1");
  FirebaseMessaging.getInstance().subscribeToTopic("country2");
  </code></pre>
  
  <p>Similarly, I would simply use <code>unsubscribeFromTopic("country1")</code> and <code>unsubscribeFromTopic("country2")</code> for unsubscribing users from topics.</p>
  
  <p>I would appreciate if you could help by letting me know if my statements are correct or if you see that I am misunderstanding the conceptual differences between "topic messages", "target messages", and "user segments". Thank you.</p>