guardian / mobile-n10n

n10n for nOTIFICATIOn
Apache License 2.0
26 stars 4 forks source link

LIVE-6627 Fix the handling of unregistered token errors from Firebase API #1239

Closed waisingyiu closed 4 months ago

waisingyiu commented 4 months ago

What does this change?

We often receive alerts from android sender lambda about Firebase API returning 404 Requested entity not found errors.

From the documentation, the error is raised when the device token we want to send a notification to is invalid, is unregistered, or has expired. A device token becomes unregistered when, for example, the user uninstalls / reinstalls the app. So it happens in normal situation.

This PR checks the details field of error messages from Firebase API and identifies invalid token errors. The notification service already has a component to delete invalid tokens from the registration database.

How to test

We deployed to CODE and sent a test notification. A notification was received successfully on my Android emulator. The logs showed that some invalid token errors were returned by Firebase APIs and those tokens were then sent to a SQS for cleanup lambda to pick up. Screenshot 2024-06-10 at 10 17 16

The log message also showed that we were able to identify invalid tokens from the 404 response, where the FCM error code is Unregistered and the message is Requested entity not found.

Screenshot 2024-06-10 at 10 17 33

github-actions[bot] commented 4 months ago

Deploy build 4409 of mobile-n10n:notificationworkerlambda to CODE

All deployment options - [Deploy build 4409 of `mobile-n10n:notificationworkerlambda` to CODE](https://riffraff.gutools.co.uk/deployment/deployAgain?project=mobile-n10n%3Anotificationworkerlambda&build=4409&stage=CODE&updateStrategy=MostlyHarmless&action=deploy) - [Deploy parts of build 4409 to CODE by previewing it first](https://riffraff.gutools.co.uk/preview/yaml?project=mobile-n10n%3Anotificationworkerlambda&build=4409&stage=CODE&updateStrategy=MostlyHarmless) - [What's on CODE right now?](https://riffraff.gutools.co.uk/deployment/history?projectName=mobile-n10n%3Anotificationworkerlambda&stage=CODE)

From guardian/actions-riff-raff.