PWA Push notification is sending doubles

0
Hi,I implemented the push notifications to my PWA. Somehow i always get the push notification 2 times on my phone when i test my messages from the standard module. When i debug the microflow i see only 1 message object. And my device is only 1 time registered ofc.Any clues?
asked
2 answers
0

Would you mind checking whether there are two entries for the same user in the push subscription/device table? In particular, if there are two different endpoint values, that would clearly explain why the same notification is being delivered twice.


As a quick test, could you also try uninstalling the PWA from your phone, then clearing the site data in the browser(permissions and storage), reinstalling the PWA, and testing again? This usually clears out any old subscriptions and recreates a single, clean one.


answered
0

Hi,


This is expected behavior in a Mendix PWA and is not caused by duplicate messages or device registrations.

When the PWA is open or in the foreground, the push notification can be handled twice:

Once by the service worker (background push handling)

Once by the Mendix client runtime (foreground handling)

As a result, the same notification is displayed twice on the device, even though:

Only one message object is created

Only one device is registered

The duplication happens on the client/PWA side, not in the microflow.


Resolution:

Ensure that notifications are shown in only one context:

Let the service worker handle background notifications only, and

Suppress notification display when the app is active in the foreground (or vice versa).

This is a common PWA push-notification pitfall and not a bug in Mendix.

answered