How to receive custom data in push notifications with Capacitor to identify which one to remove

I’m building a chat app with Capacitor and would like to remove a message’s push notification if you view the message in the chat or when a message is removed.

When using PushNotifications.addListener('pushNotificationReceived', ...) you receive a PushNotificationSchema which contains all the custom data that was sent with the notification like an ID or URL. But when using PushNotifications.getDeliveredNotifications() you receive a DeliveredNotifications which doesn’t. This makes it hard to identify which push notification to remove.

Does anyone know how to solve this?

Thank you!