Reputation: 339
I'm new to Firebase and hope someone can give advice.
In my scenario, I want to send one notification to each new user, exactly one day after registration to my app. How best to archive this?
I'm using the Firebase console, but eventually want to trigger the notification using the HTTP API (https://fcm.googleapis.com/fcm/send).
I see that you can target users 1) by topic, or 2) individually using the registration token of one or up to 1000 users.
1) As far as I understand, the "topic" approach would mean that I create a topic "Welcome message" and subscribe users to this topic if they registered one day ago, and then unsubscribe them after I send the message. Somehow this seems like a dirty solution and not using topics how they are meant to be used.
2) For the individual approach, I think I would need my app to send the registration token to my back end (and update it whenever it changes), where I then run queries to get all member tokens of those who registered yesterday, and create an array of all those tokens in the payload of my API call to FCM. Like this, I need to create an API endpoint on my back end to receive and store tokens.
Is there an easier way to archive this?
This scenario is only one example, eventually I want to have several notifications send to different subsets of my users as audiences.
Upvotes: 0
Views: 890
Reputation: 337
If the purpose is to just notify, you can use AlarmManager to set an alarm after 1 day and create a BroadcastReceiver to generate a notification when the alarm goes off.
Upvotes: 2