From 7eba96823eff9f043b398013ceea1ac46d7c6d4b Mon Sep 17 00:00:00 2001 From: Lee Phillips Date: Wed, 24 Jan 2024 14:27:03 -0500 Subject: [PATCH] Add signInFailed check to prevent hanging on hot reload. --- games_services/darwin/Classes/Auth.swift | 17 ++++++++++++++++- games_services/pubspec.yaml | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/games_services/darwin/Classes/Auth.swift b/games_services/darwin/Classes/Auth.swift index dfbd131..f659ce4 100644 --- a/games_services/darwin/Classes/Auth.swift +++ b/games_services/darwin/Classes/Auth.swift @@ -5,11 +5,26 @@ import FlutterMacOS #endif class Auth: BaseGamesServices { + + // track if previous sign in was cancelled (failed) for debugging + // this prevents hanging on `signIn` when hot reloading + #if DEBUG + var debugSignInFailed = false + #endif func authenticateUser(result: @escaping FlutterResult) { + #if DEBUG + if (self.debugSignInFailed) { + result(PluginError.failedToAuthenticate.flutterError()) + return + } + #endif currentPlayer.authenticateHandler = { vc, error in guard error == nil else { - result(error?.flutterError(code: .failedToAuthenticate)) + #if DEBUG + self.debugSignInFailed = true + #endif + result(error!.flutterError(code: .failedToAuthenticate)) return } if let vc = vc { diff --git a/games_services/pubspec.yaml b/games_services/pubspec.yaml index 4852b52..9721440 100644 --- a/games_services/pubspec.yaml +++ b/games_services/pubspec.yaml @@ -1,6 +1,6 @@ name: games_services description: A new Flutter plugin to support game center and google play games services. -version: 4.0.0 +version: 4.0.1 homepage: https://github.com/Abedalkareem/games_services repository: https://github.com/Abedalkareem/games_services issue_tracker: https://github.com/Abedalkareem/games_services/issues