From 5061fcacedb0cb3625bb22b9befe01e5f1d114b6 Mon Sep 17 00:00:00 2001 From: dab246 Date: Mon, 4 Dec 2023 10:55:28 +0700 Subject: [PATCH] TF-2298 Add document `adr` for register firebase registration token flow Signed-off-by: dab246 (cherry picked from commit 121384a5b8af06e21d470962c31b0096feed455d) --- ...r-firebase-registration-token-guideline.md | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 docs/adr/0032-register-firebase-registration-token-guideline.md diff --git a/docs/adr/0032-register-firebase-registration-token-guideline.md b/docs/adr/0032-register-firebase-registration-token-guideline.md new file mode 100644 index 000000000..76767802a --- /dev/null +++ b/docs/adr/0032-register-firebase-registration-token-guideline.md @@ -0,0 +1,28 @@ +# 17. Register firebase registration token guideline + +Date: 2023-11-24 + +## Status + +Accepted + +## Context + +The logic of firebase registration is complicated to follow by all developers + +## Decision + +Brief the logic flows to easier in following the changes of firebase registration implementation + +- `onFcmTokenChanged`: Listen for token changes from FCM (Firebase Cloud Message) +- If there is a new `token`, we will send a request to the jmap server to check if this token has been registered `GetFirebaseRegistrationByDeviceIdInteractor`. +`deviceClientId` is a unique key generated based on `token` and `platform` +- On the contrary, if no new token is generated, we will retrieve the `deviceClientId` stored in `cache` to call back the request to the above jmap server. +- If the status after sending the request to the jmap server returns successful `GetFirebaseRegistrationByDeviceIdSuccesss`. +We perform a check to see if `FirebaseRegistrationTokenExpired` has expired or not (The check is performed before `3 days`). +If it expires, we will send a request to update `expires` for this `FirebaseRegistration` to increase the lifetime by `7 more days`. +- Conversely, if we receive `GetFirebaseRegistrationByDeviceIdFailure` we will send a request to register a new `FirebaseRegistration` + +## Consequences + +- Any change to `Push notifcation` should be updated in this ADR