The GoogleSigninReusabelComponets for iOS is the easiest way to get data from Google.
- Get Specific user data from Google
- iOS 11.2+
- Xcode 14.3
Note: For Xcode version lower than 14.3 use version 2.0.1
Import two files in your project and it's done
- Configure Google App Settings for iOS (https://developers.google.com/identity/sign-in/ios/sign-in?ver=swift)
- Download Google SDK Or Pod's for iOS
- Add SDK to the Project
- Configure Xcode Project
- Connect App Delegate Using LoginManager.swift Methods
- Congratulations!
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation:
Any) -> Bool {
return SSGoogleManager.manager.handleOpenUrl(app: app, url: url)
}
SSGoogleManager.manager.logInWithGoogle(clientId: <Client_ID (StringFormat)>, presenting: UIViewController) { result in
switch result {
case .success(let userData):
print(userData)
case .failure(let error):
print(error.localizedDescription)
}
}
didDisconnectBlock: { result in
switch result {
case .success(let userData):
print(userData)
case .failure(let error):
print(error.localizedDescription)
}
}
SSGoogleManager.manager.logInWithGoogle(clientId: <Client_ID (StringFormat)>, controller: self, complitionBlock: { (userData, error) in
if error == nil {
print(userData ?? "")
} else {
print(error?.localizedDescription ?? "")
}
}) { (userData, error) in
if error == nil {
print(userData ?? "")
} else {
print(error?.localizedDescription ?? "")
}
}