We are using firebase authentication with OTP for authenticating users into an android app and also for the chat and other firebase features. The chat is stored in a real-time database.
It's a services app where users buy services from service providers. The app normally stays logged in for weeks and months. However, the firebase user starts returning null if the user opens the app later. (firebase token expires after one hour)
I have read many articles that the firebase token can be refreshed just before it expires or upon expiry. However in our situation, when the user comes back, the token has already expired and it can no longer refresh the token. the getIdToken or any other methods do not work if the token has already expired.
One way would be to check every hour or 40 minutes to refresh the token but that would be an overkill if the user does not use the app and it keeps refreshing the token.
Is there any other way that when the user returns, the token Is refreshed upon opening the app?