I have a problem with Google Auth.
If the user has signed in Gmail account on the phone I want to open a Credential Manager so that the user could choose an account he wants to use to authenticate in my app.
If the user has no signed in gmail account on the phone I want to open a sign in page so that he could input his gmail account/password and sign in.
Using this cose: GoogleSignIn.getLastSignedInAccount(requireContext()) I try to find out if there is signed in account on the devise or not. But oogleSignIn.getLastSignedInAccount(requireContext()) still returns instance even if there is no logged in account on the phone. What can I do with it? Maybe there is another aproach?
val account = GoogleSignIn.getLastSignedInAccount(requireContext())
if (account == null) {
intentLauncher?.launch((viewModel.getGoogleSignUpIntent()))
} else {
viewModel.openGoogleAuthWindow(credentialManager, requireContext())
}
But when I close the app and sign out from the gmail account and relaunch the app I still have account not null. Do you have an idea how to handle this?