diff --git a/CodetrixStudioCapacitorGoogleAuth.podspec b/CodetrixStudioCapacitorGoogleAuth.podspec
index 6432925..acb8cf6 100644
--- a/CodetrixStudioCapacitorGoogleAuth.podspec
+++ b/CodetrixStudioCapacitorGoogleAuth.podspec
@@ -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
diff --git a/README.md b/README.md
index d35bdd2..1649757 100644
--- a/README.md
+++ b/README.md
@@ -147,14 +147,11 @@ or see more [CapacitorGoogleAuth-Vue3-example](https://github.com/reslear/Capaci
1. Create in Google cloud console credential **Client ID for iOS** and get **Client ID** and **iOS URL scheme**
-2. Add **identifier** `REVERSED_CLIENT_ID` as **URL schemes** to `Info.plist` from **iOS URL scheme**
- (Xcode: App - Targets/App - Info - URL Types, click plus icon)
+2. Add **identifier** `GIDClientID` to `Info.plist`
+ `GIDClientIDVALUE`
-3. Set **Client ID** one of the ways (by order of importance in the plugin):
- 1. Set `clientId` in initialize method
- 2. Set `iosClientId` in `capacitor.config.json`
- 3. Set `clientId` in `capacitor.config.json`
- 4. Set `CLIENT_ID` in `GoogleService-Info.plist`
+3. Add **identifier** `REVERSED_CLIENT_ID` as **URL schemes** to `Info.plist` from **iOS URL scheme**
+ (Xcode: App - Targets/App - Info - URL Types, click plus icon)
### Android
diff --git a/ios/Plugin/Plugin.swift b/ios/Plugin/Plugin.swift
index be9b54d..8eb048d 100644
--- a/ios/Plugin/Plugin.swift
+++ b/ios/Plugin/Plugin.swift
@@ -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);
+ }
}
}
}
@@ -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);
}
}
@@ -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(),