GoogleSignInClient account picker not showing after log out

Viewed 150

I'm implementing Google Sign-in through GoogleSignInClient's SignInIntent for the Play Services functionality in my Xamarin.Android app and I need the account picker to show every time. However, when I sign out through _signInClient.SignOutAsync() then sign in again, the account picker doesn't show up anymore and automatically selects the previous account that I used. This issue still happens even if I have multiple accounts signed in to my device.

Clearing the Google Play Services cache through the Android setting solves this issue, but this is not really an ideal solution for an average user.

I tried using ClearDefaultAccountAndReconnect(), but I am receiving the error:

Method is not supported by connectionless client. APIs supporting connectionless client must not call this method.

    var client = _signInClient.AsGoogleApiClient();
    if (client.HasConnectedApi(Auth.GOOGLE_SIGN_IN_API))
    {
        await client.ClearDefaultAccountAndReconnect();
    }

    await _signInClient.SignOutAsync();

Is there a recommended way to approach this? (Implementations in Android are also appreciated)

Thanks!

Note: I'm not using Firebase nor other Google services. I only need the login to access the achievements from Play Services.

1 Answers

This seems to be a OS specific issue. I'm facing this issue on Android 9 devices, but not on Android 11 devices. On Android 9 device, i was able to get back account picker screen only after restarting the phone. This is the code i'm using

 gsc.signOut().addOnCompleteListener {
     val intent = gsc.signInIntent
     gmailIntentLauncher.launch(intent)
 }

It is working as expected on Android 11 devices.

Related