Search code examples
javascriptpush-notificationfirebase-cloud-messagingweb-push

FCM push notifications queuing up if browser is closed / Web-push


When browser is closed, every push notification that has been sent in the meantime is queued up, which leads to receiving hundreds of notifications when I open the browser for the first time next day. Is there a way of stopping push notifications queuing up?


Solution

  • An option is to make use of time_to_live:

    This parameter specifies how long (in seconds) the message should be kept in FCM storage if the device is offline. The maximum time to live supported is 4 weeks, and the default value is 4 weeks. For more information, see Setting the lifespan of a message.

    and set it to your desired time. Basically it determines until only when FCM would keep the message on the queue.