2

I am using Firebase (FCM) in a project, where I use the topic feature to send out daily notifications to many different users in various timezones. Notifications are always sent out, when the user's time is 12:00PM, in order to achieve this, I create a unique topic every day, for the batch of users I am going to notify. At the moment our topics could look like: x_daily_notification_1550152751 - Previously I had a system that would create static topics based on the timezone, so users could be subscribed to a topic like: x_daily_notification_europe_london, but this proved to be too unreliable and hard to manage, due to users moving between timezones.

The way the system works is based on research and advise from this question I made late last year: FCM topic limits and expiration/invalidation of old unused topics?

So to sum it up:

  1. Bulk subscribe users to a topic
  2. 5 minutes later, send out the topic. The delay is due to not knowing if FCM waits for all the bulk subscriptions to process, before sending out the notifications
  3. 10 mins after sending the topic, unsubscribe all tokens from the topic again, deleting the topic from FCM.

The reason for these delays, is that I have noticed that sometimes we do not get the notifications. The only reason I can think of, is because we send and unsubscribe the topic too fast, so if 100K users were to be notified and we deleted it straight away, only a few would get it. It seems that FCM does not wait for one request to finish before another is processed.

Even though I wait 10 minutes before I unsubscribe, it seems that sometimes not all users get notified, which could mean that they were not processed before I unsubscribed them again, so I would like to wait longer before I unsubscribe everyone from the topic, to ensure that they have received the notification. The first solution I thought of was to just wait, until the next batch is ready to be processed and then delete the previous topic, which would be about an hour later, where I can be more or less sure that everyone has received the notification at that point.

My real question is, do I need to unsubscribe at all? It could get messy on Firebase' end, but surely they have systems in place to handle this, as it does not mention anything in the documentation about cleaning up.

Severin
  • 962
  • 5
  • 21
  • This seems like a really uncommon way to use topics. Why don't you just use a single message-of-the-day topic? – Frank van Puffelen Feb 14 '19 at 14:49
  • As I wrote in the question, I sent the notification to users where timezone is 12:00PM, so if I just created one topic per day, then the "early users" would keep getting it, unless I unsubscribed them from it again, before the next batch of users reach 12:00PM. So Stockholm, Oslo, Copenhagen, ..., would get a topic and London, Dublin, ..., would get another topic. – Severin Feb 14 '19 at 14:59
  • Topics are a cheap way for us to constantly notify a lot of users, without having to process single notifications ourselves. We bulk subscribe a lot of users, send the topic and then forget about it, so we do not have to manage a lot of things. This may be a uncommon way to use it, but as discussed in the old question I linked in this question, other people have used it the same way and nothing in the documentation is against this approach. But I do agree it's special. – Severin Feb 14 '19 at 15:01
  • Your time-zone specific use case could also be met by having a topic per time zone. I still don't see why you need a daily topic, which is what I think is leading to your problems to begin with. – Frank van Puffelen Feb 14 '19 at 16:10

0 Answers0