diff --git a/src/Auth.Google/Auth.Google.csproj b/src/Auth.Google/Auth.Google.csproj index 0872930..cf28412 100644 --- a/src/Auth.Google/Auth.Google.csproj +++ b/src/Auth.Google/Auth.Google.csproj @@ -90,7 +90,7 @@ - + diff --git a/src/Auth.Google/Platforms/iOS/FirebaseAuthGoogleImplementation.cs b/src/Auth.Google/Platforms/iOS/FirebaseAuthGoogleImplementation.cs index 1a41c6b..765dfa2 100644 --- a/src/Auth.Google/Platforms/iOS/FirebaseAuthGoogleImplementation.cs +++ b/src/Auth.Google/Platforms/iOS/FirebaseAuthGoogleImplementation.cs @@ -1,10 +1,10 @@ using Firebase.Auth; +using Google.SignIn; using Plugin.Firebase.Auth.Platforms.iOS.Extensions; +using Plugin.Firebase.Auth.Platforms.iOS.Google; using Plugin.Firebase.Core; using Plugin.Firebase.Core.Exceptions; using FirebaseAuth = Firebase.Auth.Auth; -using Google.SignIn; -using Plugin.Firebase.Auth.Platforms.iOS.Google; namespace Plugin.Firebase.Auth.Google; @@ -12,8 +12,9 @@ public sealed class FirebaseAuthGoogleImplementation : DisposableBase, IFirebase { public static void Initialize() { - var googleServiceDictionary = NSDictionary.FromFile("GoogleService-Info.plist"); - SignIn.SharedInstance.ClientId = googleServiceDictionary["CLIENT_ID"].ToString(); + var googleServiceDictionary = NSMutableDictionary.FromFile("GoogleService-Info.plist"); + var clientId = googleServiceDictionary["CLIENT_ID"].ToString(); + SignIn.SharedInstance.Configuration = new Configuration(clientId); } public static bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options) diff --git a/src/Auth.Google/Platforms/iOS/GoogleAuth.cs b/src/Auth.Google/Platforms/iOS/GoogleAuth.cs index ae108a5..79d3fc9 100644 --- a/src/Auth.Google/Platforms/iOS/GoogleAuth.cs +++ b/src/Auth.Google/Platforms/iOS/GoogleAuth.cs @@ -3,29 +3,25 @@ namespace Plugin.Firebase.Auth.Platforms.iOS.Google; -public sealed class GoogleAuth : NSObject, ISignInDelegate +public sealed class GoogleAuth : NSObject { private UIViewController _viewController; private TaskCompletionSource _tcs; - public GoogleAuth() - { - SignIn.SharedInstance.Delegate = this; - } - public Task GetCredentialAsync(UIViewController viewController) { _viewController = viewController; _tcs = new TaskCompletionSource(); - SignIn.SharedInstance.PresentingViewController = viewController; - SignIn.SharedInstance.SignInUser(); + SignIn.SharedInstance.SignInWithPresentingViewController(viewController, DidSignIn); return _tcs.Task; } - public void DidSignIn(SignIn signIn, GoogleUser user, NSError error) + public void DidSignIn(SignInResult signIn, NSError error) { + var user = signIn.User; + if(user != null && error == null) { - _tcs?.SetResult(GoogleAuthProvider.GetCredential(user.Authentication.IdToken, user.Authentication.AccessToken)); + _tcs?.SetResult(GoogleAuthProvider.GetCredential(user.IdToken.TokenString, user.AccessToken.TokenString)); } else { _tcs?.SetException(new NSErrorException(error)); }