I am creating a solution that permit other app editor to sent notifications to their app through Firebase Cloud Messaging, and I want to develop the possibility to do A/B Testing.
I came across the groups syteme of FCM and, if that works, it would be a good way to separate audiences in two or three groups, as it is possible to register several devices at the same time in a group. However it seems to be designed to represent the devices of a single user, which means a small number of devices.
So my question is, can we still use FCM grouping with a large number of devices (in the tens of thousands) ? Or can they not be used this way?
No. Device Groups have a limit of 20 tokens per group:
The maximum number of members allowed for a notification key is 20.
High volume tokens in a group could be handled by Topics better.
I realize you asked this question six month ago, but for anybody who is looking to A/B test their notifications using Firebase Cloud Messaging, this functionality is now directly built into the Firebase Notifications panel. I'd recommend checking out the documentation, and heading right into the Notifications panel of the Firebase Console to start building your A/B test.
Related
Hello Everyone,
I have create gmail app and complete all types of functionality but one functionality not implemented this one is mail receive in our gmail app.
Me search any types solution for receive mail and i have found one solution is google cloud Pub/Sub but this pub/sub how to implemented in our app is not idea show please tell me any one how to used pub/sub in android.
Cloud Pub/Sub is not the right choice for receiving messages on Android. The service is designed for inter-service communication. Using it on Android would present two problems:
The limit on the number of topics and subscriptions per project. Only 10,000 topics and subscriptions are allowed and only 10,000 subscriptions per topic. If you plan to scale out to many devices, you will run up against these limits quickly.
Security/authentication issues. You would need to ship the credentials within the Android application and so you will either have to generate service accounts for every individual device or use the same one across all devices. What do you do if those credentials are compromised? In the former case, you have to keep track of all of them and revoke the right one. In the latter case, revoking the privileges means all of your devices stop working.
You need something like Firebase Cloud Messaging to send data to Android devices. You may use Cloud Pub/Sub as a means to generate notifications out of GMail, but the subscriber would be another server-side application or perhaps a Cloud Function that passes the notification on via Firebase Cloud Messaging.
I am new with FCM and I am still discovering its possibilities.
I wonder if it is the right tools to do what I want:
I would like to send a notification to all my users, to inform them about new informations for example.
The difficulty is that I want to target all the users of different apps (like 10 apps), and some of them may have more than one of my app installed.
So I do not want a user to have the same notification displayed multiple times (if he installed more than one of my app).
Is it something possible with Firebase?
Thank you
Yes you can! To achieve this, i recomand you using Google Cloud Messaging not FCM. which it's an earlier version. Here is a tutorial on how you can migrate from FCM to GCM.
To achieve this, all your 10 apps must use Firebase and all your users must be Firebase registered users. To send a notification to all devices, would mean then to select all the registration ids from that database, add them in an array and pass them further to GCM.
Note also, that strating with GCM 3.0 it's now possible to send a notification to all devices thanks to topics support. The app must suscribe to one or more topics and the server can send notifications to that topic without specifying individual devices. You can see here Topic Messaging.
Unfortunately, there is no way in which, with a single line of code, to send a notification to all of your users from all your apps. You can only send a notification to all your users that belong only to a single app. If you want that all of yours to get the same message, then you need to consider sending that particular message again, to all users that belong to each app. In this case, if a users is using more then one of your apps, will receieve that message for each app separately.
Just been doing a bit of research on the different ways to send/receive remote notifications and many answers suggested GCM (now FCM). From what I can understand, this seems feasible for a small scale app that can support 100 online users (free) or 10k users (paid). But I fail to see how it is feasible for a background type notification system which, to be frank, are expected of most apps these days.
Hypothetically, if an app has 1mil users, then there will need to be 1mil simultaneous connections sitting in the background for the notification to reach its user in a timely fashion.
Or am I misinterpreting the "simultaneous" part? When does it apply?
Their FAQ doesn't go into too much details here.
The limit on "simultaneous database connection" refers the usage of the database API.
To receive notifications (whether the app is in background, open, or closed doesn't matter) through FCM (or GCM is the same) your app doesn't need to keep any connection open.
The firebase SDK together with the each platform operative system will take care of that.
Is GCM the only way for push notifications in android? And is it advisable over other methods (if there are any)?
So let's say my app from a device registers on GCM. Is it the app itself which is assosciated with the device that registers itself, or the user and his email id that register? If my user switches devices in future, will the same 'registration token' work for him ? Or in a similar scenario if a user with another g-mail id registers to my app from the same device, do i push notifications to the same device with 2 different registration tokens?
Extending to what i asked in 2, suppose a single user has his g-mail id working on my app on different devices. Does GCM push the notification to all those devices, or only one of them? And if one, then how does it prioritize?
No, there are other push notification services in Android, like Parse. However, it is strongly recommended to use the default push notification service that is present in any Android device that has Google Play Store, because that reduces battery usage. If you are pushing your app somewhere else though, like Amazon Store, keep in mind that Kindle Fire does not comply with this and doesn't have Google Play Services -- at least as far as I know.
The registration token is very volatile and is not bound at all to an email. Actually, sometimes the same device may get a new GCM ID out of the blue. There are many tutorials on GCM's best practices, but Google's is the best way to start. What you should do to prevent problems is store the GCM id of your device in your database, so you can always know which ID is currently associated to your device. GCM may give you new IDs for no reason, so always parse its response properly and store the new ID it may provide, linking it to the device.
GCM doesn't really care which Google account is your app using. That means you can register as many devices as you want with the same account. You have to manage to which devices you push notifications, because the ID is managed by device.
Be careful: there's been some changes with the API lately, so a lot of unnoficial tutorials you find on the internet may point to deprecated methods.
There are other ways of sending notifications, Tokodu and RabbitMQ for example. I wont go over if X is better than Y, since it's not allowed on StackOverflow.
A unique device token is generated for the device, how you use this device token is totally up to you. You can make it unique for the user by, for example, implementing a login system, so that the device token is created and stored in a database (together with the user information). Let's say if two different users uses your application on a shared device, they can both receive notifications on the same device if you allow them to. It depends on your own implementation.
This again depends on how you chose to implement the GCM features on your client and server side. For example, you can choose to store device tokens for each and every device the user has installed the app on, or you can store the latest device token so that notifications are only sent to one of the user's devices.
I hope this helps clear some things up.
Besides good answers above, if you need a push notification solution for a working environment without Internet access, I suggest SignalR of Microsoft, which has already supported Android and Java (you can find out more at GitHub).
Hope this helps little!
I want to avoid the complexities of managing Device Tokens at the application level
One user using multiple devices on iOS and Android
Multiple users subscribed to an application group
Treating #1 and #2 as topics on GCM is obviously an easy solution.
So that I only have to deal with my Application UserIds and GroupIds while sending notifications.
1) When device is registering (iOS/Android), I just subscribe the device to topics ["USER_A", "GROUP_A", "GROUP_B"]
2) When sending a notification, just send to a topic.
However, that means, number of topics = users + groups.
1 million users + 500K groups = 1.5 million topics on GCM
My question is..
Is there any limit to the number of topics on GCM?
Is there a better approach to avoid managing device subscriptions without having to deal with its complexities when delivering messages.
For #1:
Nope. As per their blog last December 2015:
We’re now happy to announce that we’re allowing unlimited free topics for your app. This means app developers can place an unlimited number of devices within each topic and create an unlimited number of topics.
As far as I know, there still hasn't been any changes with regards to the number of topics.
For #2:
I think it pretty much depends on your preference. For your use case in #1, I think that Device Group Messaging is the one to use. But since you're aiming to avoid too much complication, I think what you did using Topic Messaging is pretty much it. I actually found this post that kinda discusses what to use between the two, the comments are very enlightening, if you will. :D
Cheers! :)
GCM has removed the limitations on Topics as well as subscriptions
FCM also supports the same
Check This: https://firebase.google.com/docs/cloud-messaging/android/topic-messaging