rokwire / notifications-building-block

The Notifications Building Block manages user notifications for the Rokwire platform.
Apache License 2.0
1 stars 1 forks source link

[FEATURE] Remove invalid FCM tokens #116

Open shurwit opened 1 year ago

shurwit commented 1 year ago

Is your feature request related to a problem? Please describe. Currently we accumulate FCM tokens indefinitely which leads to significant unnecessary overhead when notifications are sent.

Describe the solution you'd like We should remove tokens that are no longer valid to reduce the clutter. It looks like we may receive a specific error message from Firebase when we attempt to send to an invalid token:

http error status: 404; reason: app instance has been unregistered; code: registration-token-not-registered; details: Requested entity was not found.

There may be other cases in which we want to remove these tokens as well but we will need to be careful not to remove them based on errors that are due to a temporary state.

shurwit commented 8 months ago

Hi @martin-rokmetro, you can find the function call that sends the notification to a specific token that may return the error mentioned above here: https://github.com/rokwire/notifications-building-block/blob/5ca50b79072fc10a83120f5c447a7c7581550858/core/app_queue.go#L254