Skip to content

Problem with old Play Games account #197

@wantroba

Description

@wantroba

Recently, an app user contacted me reporting a problem. After thorough evaluation, I discovered that the app didn't return the await GameAuth.signIn(); call, nor did it throw an exception.

I asked him to change the settings in Play Games to always ask for the player profile when logging into the app. When he opened the app and selected the profile he'd had for many years, the app wouldn't progress and would get stuck on the call I mentioned above await GameAuth.signIn();. When he opened the app and clicked "Cancel," that is, without selecting any profile, the app worked without issues (since I allow the user to play without being logged into a Play Games account). I asked him to create another profile in Play Games, and the await GameAuth.signIn(); call executed correctly, and everything worked as expected.

I couldn't debug it because he's a user who kindly performed the steps I requested remotely. I'll leave his phone settings:

Samsung Galaxy A32
Android 13 (SDK 33)
Play Games account approximately 15 years old.

Edit:
I assumed the app was stuck on this call await GameAuth.signIn();, but there's a chance it's stuck somewhere else. So I'll paste the full code for that part here:

try {
        if (!(await GameAuth.isSignedIn)) {
          await GameAuth.signIn();
        }
        firebaseAuthPlayerId = await _firebaseAuthSignIn();
        displayName = await GamesServices.getPlayerName();
        gameServicesId = await GamesServices.getPlayerID();
      } catch (e) {
        FirebaseUtils.recordError(e, StackTrace.current);
      }

static Future<String?> _firebaseAuthSignIn() async {
    try {
      String? uid;
      if (Platform.isAndroid) {
        final authCode = await GameAuth.getAuthCode(
            "{mycode}.apps.googleusercontent.com");
        if (authCode != null) {
          final userCredential =
              await FirebaseAuth.instance.signInWithCredential(
            PlayGamesAuthProvider.credential(serverAuthCode: authCode),
          );
          uid = userCredential.user?.uid;
        }
      } else if (Platform.isIOS) {
        final userCredential = await FirebaseAuth.instance
            .signInWithCredential(GameCenterAuthProvider.credential());
        uid = userCredential.user?.uid;
      }
      return uid;
    } catch (e) {
      FirebaseUtils.recordError(e, null);
      return null;
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions