I have been trying to implement a checked box where is user says keep me signed in they stay signed in. The problem however is I am wondering how can I store this value in the pref and and if its positive they just log in.
in my viewModel I have this function
fun keepSignedIn(updatedValue: Boolean){
keepSignedIn.value = updatedValue
}
and in my content screen
@Composable
fun KeepMeSignedInCheckBox() {
Checkbox(checked = state.keepMeSignedIn, onCheckedChange = keepMeSignedIn.invoke(it))
}
I am wondering what is the best way to update this value in the view Model? I have my login function in the view model too.
What I have tried,
fun keepSignedIn(updatedValue: Boolean){
keepSignedIn.value = updatedValue
val signedIn = instance().keepUserSignedIn
if(signedIn){
loginUser
}
}
But my approach does not work when I leave the app it take me to login screen, and does not store that session.