How to set WonderPush to avoid stacking notifications and to display the most recent only?

tech
how-to

#1

You want to prevent someone who has not consulted his browser for a while to have a pile of last notifications. You would like to limit the number of notifications displayed on the user’s device.

There are two complimentary approaches to this.

Using expiration dates (TTL)

This approach limits the number of notifications received by a device when it comes back online after a long period, typical of desktop computers.

When configuring your notification in the dashboard, you will find an Expiration section under the Advanced tab:
image
As highlighted, if the device was unable to receive the notification for 72 hours, it won’t receive it at all.

When using the Management API, you can control this using the push.expirationDate (with a date) or push.expirationTime (with a duration) in the notification parameter of the POST /v1/deliveries call.

This prevents a firehose of notification when switching a device back on. However always-on devices will receive all alerts, typical of mobile devices.

Using tags (in the API)

When using the Management API, you can control this using the alert.tag in the notification parameter of the POST /v1/deliveries call.
If a notification is received and uses the tag foo and there is an existing notification using the exact same tag, the new one will replace the existing one, thus limiting the number of stacked notification to 1.
If you use multiple tags, you will hence have at most 1 notification per tag.

If you provide no tag, WonderPush uses the campaignId by default, thus every notification send in a given campaign will automatically replace the previous one.

This means that if you edit your campaign’s message in the dashboard and trigger a new delivery, it will replace any previously displayed notification. However statistics won’t be able to display per delivery statistics.
We are working on a better solution for this usage.


#2