Hi folks
We need to refresh my access token few minutes before its expiry (current expiry 30 mins) to get new token and make API calls for user.
Every time user is entering into app foreground or launching app again, we are calculating remaining time to refresh token.
In application scope, a coroutine is taking care of refreshing token (api call) after the suspended delay(timeRemainingInRefreshtoken).
Haven't used WorkManager as we don't want the task to be persisted and not refresh token in background as user might not return to app for days so refreshing every 30 mins will be waste of resource. Not required to refresh in doze mode so not used AlarmManager either.
In terms of efficiency of resources which API is best.
delay()
WorkManager
AlarmManager?