Difference between topic messages, target messages, and user segments in Firebase Cloud Messaging
The conceptual answer that I was looking for is at https://firebase.google.com/docs/cloud-messaging/android/send-multiple
Send Messages to Multiple Devices: Firebase Cloud Messaging provides two ways to target a message to multiple devices:
Topic messaging, which allows you to send a message to multiple devices that have opted in to a particular topic.
Device group messaging, which allows you to send a message to multiple devices that belong to a group you define.
How to subscribe to a topic in firebase cloud messaging from device
You seem to be using the Admin SDK for server-side Java code. This SDK should only be used in trusted environments, such as your development machine, a server you control, or Cloud Functions. Using the Admin SDK in your client-side Android code is a security risk, as it allows malicious users to get administrative access to your Firebase project.
The solution is to follow the documentation for Android developers on subscribing to a topic. When you do that, the code should look like this:
FirebaseMessaging.getInstance().subscribeToTopic("weather")
Firebase Cloud Messaging Unsubscribe from all topics
You can use a condition
to send to folks who have only subscribed to v2 and not v3.
condition: "'v2' in topics && !'v3' in topics"
Note that this allows up to 5 clauses only, so I'd recommend also updating the logic in your app to remove subscriptions to older versions. You don't even need to do this conditionally, so it can be as simple as:
Firebase.messaging.subscribeToTopic("v3");
Firebase.messaging.unsubscribeFromTopic("v2");
Firebase.messaging.unsubscribeFromTopic("v1");
If the user is not/no longer subscribed to a topic, calling unsubscribeFromTopic
doesn't do anything (but doesn't fail).
Firebase Cloud Messaging No of Topics Topic Limit?
Does this mean we can have an maximum of 2000 topics per app?
You can have 2000 topic subscriptions per app instance. Otherwise, you can have as many topics as you want, disregarding what individual app instances might expect from them.
what does App instance mean?
An app instance is a unique installation of an app, separate from other installations of the same app on other devices.
Firebase best practises with FCM topics or device groups
I'd definitely pick topics for your use-case, they're pretty much made for this. While option 1 would also be possible, it just feels senseless to manage the subscriptions yourself in this case.
If you want to allow someone to also subscribe to news about all artists, create a topic all
and then send news about any artist to a condition: ('The Beatles' in topics || 'all' in topics)
.
Related Topics
Android Studio: Application Installation Failed
Android Simplecursoradapter Doesn't Update When Database Changes
How to Remove the Top and Bottom Space on Textview of Android
Put a Progressbar on Actionbar
Pass List of Objects from One Activity to Other Activity in Android
Unsigned APK Can Not Be Installed
How to Access Localhost from a Genymotion Android Emulator
How to Get All Child's Data in Firebase Database
Android Xml Rounded Clipped Corners
How to Create a Number Picker Dialog
Start Activity Using Custom Action
Android: How to Refresh Listview Contents
Open Android App from Url Using Intent-Filter Not Working
How to Correctly Pass Unique Extras to a Pending Intent
Detect If an App Is Installed from Play Store
How to Get Documents in an Android Directory That Phonegap Will See