Implementing web push notifications

Spiroua year ago

Hi

I am implementing web push notifications at the moment. When the app (PWA) is open, I would want the notification to appear like it would be a normal traccar "web" notification. Anton, could you please tell me which call to make when handling the incoming push message so this appears as a toast in the app?

This is the content of the push notification being handled by the browser:

Object { from: "6468001426", collapseKey: undefined, messageId: "000d22e1-b4d7-4f3d-9370-523ffcxx8131", notification: {…}, data: {…} }
​
data: Object { eventId: "1607" }
​​eventId: "1607"
​​
from: "6468001426"
​messageId: "000d22e1-b4d7-4f3d-9370-523ffcxx8131"
​
notification: Object { title: "Device: online", body: "Device online at 2023-09-16 21:00:22\n" }
​​body: "Device online at 2023-09-16 21:00:22\n"
​​title: "Device: online"

I can do something with the eventid, but what...


Second question; when clicking on the push notification when the app is not open, I would like to go to a specific page in the app instead of the standard map overview page. For example, I would like to go to the page with the specific device from the notification selected. For this I think we should add a "url" to the notification, which doesn't seem to be the case right now. Could you please tell me which url should be opened on clicking a notification?

Anton Tananaeva year ago

Please don't duplicate your questions.