Skip to content

Commit

Permalink
Update GoogleSignIn pod to 7.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael-rentman committed Oct 18, 2024
1 parent 43125e4 commit fbcbfc1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CodetrixStudioCapacitorGoogleAuth.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '12.0'
s.dependency 'Capacitor'
s.dependency 'GoogleSignIn', '~> 6.2.4'
s.dependency 'GoogleSignIn', '~> 7.1.0'
s.static_framework = true
end
45 changes: 24 additions & 21 deletions ios/Plugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,26 @@ public class GoogleAuth: CAPPlugin {
self.signInCall?.reject(error.localizedDescription);
return;
}
self.resolveSignInCallWith(user: user!)
self.resolveSignInCallWith(user: user!, serverAuthCode: nil)
}
} else {
let presentingVc = self.bridge!.viewController!;

self.googleSignIn.signIn(with: self.googleSignInConfiguration, presenting: presentingVc, hint: nil, additionalScopes: self.additionalScopes) { user, error in
self.googleSignIn.signIn(
withPresenting: presentingVc,
hint: nil,
additionalScopes: self.additionalScopes
) { signInResult, error in
if let error = error {
self.signInCall?.reject(error.localizedDescription, "\(error._code)");
return;
}
self.resolveSignInCallWith(user: user!);
};

let user = signInResult?.user;
let serverAuthCode = signInResult?.serverAuthCode;

self.resolveSignInCallWith(user: user!, serverAuthCode: serverAuthCode);
}
}
}
}
Expand All @@ -100,18 +108,13 @@ public class GoogleAuth: CAPPlugin {
call.reject("User not logged in.");
return
}
self.googleSignIn.currentUser!.authentication.do { (authentication, error) in
guard let authentication = authentication else {
call.reject(error?.localizedDescription ?? "Something went wrong.");
return;
}
let authenticationData: [String: Any] = [
"accessToken": authentication.accessToken,
"idToken": authentication.idToken ?? NSNull(),
"refreshToken": authentication.refreshToken
]
call.resolve(authenticationData);
}

let authenticationData: [String: Any] = [
"accessToken": self.googleSignIn.currentUser!.accessToken,
"idToken": self.googleSignIn.currentUser!.idToken ?? NSNull(),
"refreshToken": self.googleSignIn.currentUser!.refreshToken
]
call.resolve(authenticationData);
}
}

Expand Down Expand Up @@ -161,14 +164,14 @@ public class GoogleAuth: CAPPlugin {
return nil;
}

func resolveSignInCallWith(user: GIDGoogleUser) {
func resolveSignInCallWith(user: GIDGoogleUser, serverAuthCode: String?) {
var userData: [String: Any] = [
"authentication": [
"accessToken": user.authentication.accessToken,
"idToken": user.authentication.idToken,
"refreshToken": user.authentication.refreshToken
"accessToken": user.accessToken.tokenString,
"idToken": user.idToken?.tokenString,
"refreshToken": user.refreshToken.tokenString
],
"serverAuthCode": user.serverAuthCode ?? NSNull(),
"serverAuthCode": serverAuthCode ?? NSNull(),
"email": user.profile?.email ?? NSNull(),
"familyName": user.profile?.familyName ?? NSNull(),
"givenName": user.profile?.givenName ?? NSNull(),
Expand Down

0 comments on commit fbcbfc1

Please sign in to comment.