'How do I persist authentication state in my Kotlin firebase app?

I am building a kotlin app using FirebaseAuth and I want to add some custom rules to keep the user signed in for a time even if they are not using the app. All I could find in the docs related to this was for Web applications. https://firebase.google.com/docs/auth/web/auth-state-persistence

Is there anything like this in the docs for Android?

If not, is there a way I can get that functionality?

I was considering using SharedPreferences to store authentication state but I get the feeling there is a better way.



Solution 1:[1]

So, I was not aware that firebase users stay signed in until logged out explicitly. Understanding this solved my problem as I didn't have to write code to handle keeping the user signed in.

Solution 2:[2]

public override fun onStart() {
super.onStart()
        val user = firebaseAuth.currentUser
        if (user != null) {
            //startActivity
        } else {
            Timber.i("Error")
        }
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dylon Jaynes
Solution 2