iOS에서 AWS 모바일 허브를 구현하려고합니다. "Google로 로그인"버튼을 클릭하면 ID 브라우저에서 내 ID를 볼 수 있습니다. 여기에는 문제가 없습니다. 그런 다음 GIDGoogleUser에 액세스하려고합니다. 사용자가 구글에 로그인 한 AWS 모바일 허브 Google 인증 iOS
let googleUser = GIDGoogleUser.init()
그럼 내가 확인 :
if(AWSGoogleSignInProvider.init().isLoggedIn){
print("Success")
}else{
print("Authentication error")
}
내가 볼 '인증 오류'출력 엑스 코드에서 나는 GIDGoogleUser을 초기화하지만 사용자 정보에 액세스 할 수 없습니다. 내 실수는 어디 갔지? 그리고 어떻게하면 Google 사용자의 이메일과 이름을 얻을 수 있습니까?
AppDelegate.swift : 나는 이번 주에 같은 문제를 해결하기 위해 노력하고 발견 된
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
AWSGoogleSignInProvider.sharedInstance().setScopes(["profile","email", "openid"])
AWSSignInManager.sharedInstance().register(
signInProvider: AWSGoogleSignInProvider.sharedInstance())
let didFinishLaunching = AWSSignInManager.sharedInstance().interceptApplication(
application, didFinishLaunchingWithOptions: launchOptions)
if (!isInitialized) {
AWSSignInManager.sharedInstance().resumeSession(completionHandler: {
(result: Any?, error: Error?) in
print("Result: \(result) \n Error:\(error)")
})
isInitialized = true
}
return didFinishLaunching
}
클라이언트 정보에 액세스하려면 클라이언트의 Google 로그인 공유 인스턴스의 'currentUser' 속성을 사용해야합니다. 참조 : https://developers.google.com/identity/sign-in/ios/api/interface_g_i_d_sign_in.html#ac49bf5dabe7b89781cd58e69cb015651 –
로그인 확인을 위해 AWSSignInManager.sharedInstance(). isLoggedIn'을 사용하지 않아야합니까? – Lawliet