Setting the lifespan of web push notifications
When you send a notification, you can set a time to live (TTL) for the message: the push service will try to deliver the notification to the user for that amount of time, but the notification will be dropped if the user remains offline for a longer period. Basically using the TTL you can set an expiration for the messages and prevent the delivery of web push notifications that are no longer relevant.
Setting the TTL
You can set the TTL in different ways:
- you can choose a default TTL for all the notifications from the project settings
- you can choose a TTL for a notification from Advanced options when you send it from the dashboard
- you can set a TTL in seconds when you send the notifications using the API or libraries
For most notifications we recommend to use a TTL of 1 week, which is the default.
Setting a TTL to a low value reduces the number of deliveries and clicks. For this reason short TTL are not recommended, unless you have a good reason to do that. For example it can be appropriate to use a short TTL for a flash sale or to notify an icoming phone call.
Using the API you can even set the TTL to zero, which has a special meaning: the browser push service gives a higher priority to messages with a TTL set to 0, however, if the device cannot be reached immediately, the notification is discarded. If you use this option to notify an incoming phone call, for example, we recommend to use it together with the Urgent option.
The maximum TTL is 4 weeks, which can be useful if you want to maximize the number of deliveries. The downside is that the messages may not be relevant anymore. Also, if you send many notifications and a user turns on the device after some time, he will receive a lot of notifications.
TTL for scheduled notifications
The TTL for scheduled notifications is counted from the moment in the future when the notification is actually sent, and not from the moment when the notification is created. For example, if you create a notification on January 1 with a TTL of 1 day and you schedule it for January 5, then the notification expires on January 6.