I am using password login from Firebase Auth REST API on my Flutter app. For the tokens expire every 3600 seconds, I would like to refresh the tokens with a Timer every 50 minutes.

Do the Timers run when the app is suspended or paused? Is there a better approach?

Solution 1: farooq GV

You can use workmanager to run a periodic task. You can just set it to execute a task every "x" minutes, which in this case would be refreshing the tokens. Or the other option is to use Kotlin combined with Java within your project, which is not recommended since it is really time consuming to do so. I tried WorkManager and it's pretty straight forward.

    frequency: Duration(minutes: 50),

void callbackDispatcher() {
    Workmanager().executeTask((taskName, inputData) async{
        return Future.value(true);//Required No Matter The Task