유저 검증 (User Verify)
if(GIDSignIn.sharedInstance.hasPreviousSignIn()) {
GIDSignIn.sharedInstance.restorePreviousSignIn()
// 로그인 이후 액션
} else {
// 로그인 뷰로 이동
}
Swift
복사
프로필 정보 가져오기 (User Profile)
GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in
guard error == nil else { return }
guard let user = user else { return }
let emailAddress = user.profile?.email
let fullName = user.profile?.name
let givenName = user.profile?.givenName
let familyName = user.profile?.familyName
let profilePicUrl = user.profile?.imageURL(withDimension: 320)
}
Swift
복사
로그아웃 (Sign Out)
GIDSignIn.sharedInstance.signout()
let firebaseAuth = Auth.auth()
do {
try firebaseAuth.signOut()
} catch let signOutError as NSError {
print("Error signing out: %@", signOutError)
}
Swift
복사
연결 해제 (Disconnect)
GIDSignIn.sharedInstance.disconnect { error in
guard error == nil else { return }
// Google Account disconnected from your app.
// Perform clean-up actions, such as deleting data associated with the
// disconnected account.
}
Swift
복사