Best practice about saving FCM tokens to backend with auth #7465
Unanswered
slavko-lukic
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Seems to me that I can remove |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I ran into small issue when I'm trying to save FCM token to backend but when I have authentication implemented.
I will demonstrate on the example from docs but alter it a bit to show you what I mean.
In example above we don't want to try and save FCM token to backend because request will fail if JWT is not present, so because of that I put guard statement at the beginning of the useEffect to prevent FCM token handling if user is not authenticated.
Problem arises when user logs out which clears the FCM token and logs back in.
Then
saveTokenToDatabase
gets called twice, first time here:and second time in
onTokenRefresh
.What is the best way to handle this?
Beta Was this translation helpful? Give feedback.
All reactions