Reputation: 217
I am using FCM to send push notifications to all my android app users to tell them about new poetry and wallpapers/backgrounds added to server
Its working is like this: When user install android app first time its device token is received on our server via rest API written in php on server side and we are sending push notifications to user as soon as new wallpaper is available done via their device tokens received on our server by getting these from database in array and passing that array to FCM CURL Call in php
Our Issue: Limit reached can not be exceeded from 1000 tokens at a time
Our tries to solve that: We are sending now with for loop of each 900 users at a time in php and calling CURL to FCM in php for each 900 users again and again. Now notification are being received on some device and some are missing. Tell me how can I reliably send notifications to all devices without any limit issue instantly?
Upvotes: 0
Views: 3129
Reputation: 126684
There is a very easy solution to that. If you want to send notification to a group of users, you just have to subscribe them to a topic. For that you can use one line of code in your app FirebaseMessaging.getInstance().subscribeToTopic("<topicName>");
. A few hours after the first user subscribed to the topic, you will also be able to see it in the Firebase console. You can also subscribe users to topics using the Firebase Admin SDK.
Upvotes: 2