Skip to content

On fresh install, first authentication fails, but will succeed on the second app open. #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gnarhard opened this issue Mar 20, 2025 · 10 comments · May be fixed by #189
Open

On fresh install, first authentication fails, but will succeed on the second app open. #188

gnarhard opened this issue Mar 20, 2025 · 10 comments · May be fixed by #189

Comments

@gnarhard
Copy link

gnarhard commented Mar 20, 2025

Flutter v3.24.3
games_services: using develop branch

Seems to be working properly on the stable release.

@gnarhard gnarhard changed the title On installing a new build number, authentication fails, but will succeed on the second app open. On fresh install, first authentication fails, but will succeed on the second app open. Mar 20, 2025
@theLee3
Copy link
Collaborator

theLee3 commented Mar 25, 2025

Android or iOS?

@gnarhard
Copy link
Author

I was experiencing it on iOS. Didn't check android.

@theLee3
Copy link
Collaborator

theLee3 commented Mar 27, 2025

I am unable to replicate the behavior on iOS. Can you share the code for your auth flow? Are you seeing an error, or are you just not seeing auth succeeding?

@gnarhard
Copy link
Author

The problem was that GameAuth.isSignedIn was always returning null first from the player stream and then the true sign in value was being returned second. This would make my game assume there was no user signed into Game Center every time. No error, just unsuccessful auth. Auth flow looks like this and works perfectly on the stable release:

Future<void> signIn(
      BehaviorSubject<List<LoadingMessage>> loadProgressStream$) async {
    if (!_connectivityService.hasConnectivity) return;

    if (await Env.isEmulator) return;

    if (await isSignedIn) {
      debugPrint("Player already signed into Games Services");
      return;
    }

    try {
      await GameAuth.signIn();
    } catch (e, stackTrace) {
      debugPrint("Error signing into Games Services: ${e.toString()}");

      await ExceptionHandlerService.captureException(e, stackTrace: stackTrace);

      loadProgressStream$.add([
        ...loadProgressStream$.value,
        LoadingMessage(
          id: LoadingMessage.incrementId(loadProgressStream$),
          message: 'failed to sign into games services',
          status: LoadingStatus.error,
        )
      ]);
    }
  }

@theLee3
Copy link
Collaborator

theLee3 commented Mar 27, 2025

Thanks for the quick response. I will implement a similar flow and find the issue.

@gnarhard
Copy link
Author

My pleasure! Thank you for all of your hard work on this package.

@theLee3
Copy link
Collaborator

theLee3 commented Mar 28, 2025

Please try the patch.

games_services:
    git:
      url: https://github.com/Abedalkareem/games_services.git
      ref: bugfix/back-compat
      path: games_services

@theLee3 theLee3 linked a pull request Mar 31, 2025 that will close this issue
@gnarhard
Copy link
Author

gnarhard commented Apr 7, 2025

"Because every version of games_services from git depends on games_services_platform_interface ^4.1.1 which doesn't match any versions, games_services from git is forbidden."

I tried using a dependency_override but games_services is not linking to the path of games_services_platform_interface, it's linking to a hosted version.

@theLee3
Copy link
Collaborator

theLee3 commented Apr 7, 2025

Sorry. Please pull again, if that doesn't work, please run flutter clean then pull.

@gnarhard
Copy link
Author

gnarhard commented Apr 7, 2025

That fixed it! On a fresh install, I'm now getting proper authentication. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants