2016-07-25 2 views
1

로그인 버튼에 대한 Google 문서에 어려움을 겪고 있습니다. 기본적으로 Google 로그인 버튼을 누르는 즉시 화면에 활동 표시기를 추가하고 싶습니다. 그러나, 정말google signin button press ios

https://developers.google.com/identity/sign-in/ios/api/protocol_g_i_d_sign_in_u_i_delegate-p#a3674af917a79f4b87a58f3f8ff4d4002

  1. - signInWillDispatch:error:

    아래 문서에서 호출되는 두 기능이 있습니다 서명 된 흐름 진행 방법을 선택을 완료하지 않았다, 그리고 UI해야 더 이상 회 전자 또는 다른 "기다려주십시오"요소를 표시하십시오. 더 많이 ... - signIn:didSignInForUser:withError:

    로그인의 흐름

  2. 완료하고 오류가 전무 인 경우에 성공했다. ... 더`내가 그나마

내가 구글 로그인 버튼을 누르면 즉시 호출되는 어떤 기능을 잘 모릅니다으로 내 beginActivityIndicator 코드를 넣을 수있는 것을 알고있다.

감사합니다, 코드

--update - 다음은 내가 GIDSignInUIDelegate 및 GIDSignInDelegate에서 상속 내 loginVC에서이 네 가지 기능을한다. 꽤 많이 내가 SignInWillDispatch 전에 함수에 도착해야 활동 지시자를 시작할 수 있습니다. 그러나 문서에있는 위치를 찾을 수 없습니다. 나는 구글 제스처 인식기를 구글 버튼에 포함시켜 보았습니다. 그래도 로그인 기능은 마치 빈 UIView처럼 완전히 작동하지 않습니다.

// Google login buttob 
    GIDSignIn.sharedInstance().uiDelegate = self 
    GIDSignIn.sharedInstance().delegate = self 


    // Uncomment to automatically sign in the user. 
    //GIDSignIn.sharedInstance().signInSilently() 

    // TODO(developer) Configure the sign-in button look/feel 
    let googleSignInBtn = GIDSignInButton() 
    googleSignInBtn.frame.size = loginButton.frame.size 
    googleSignInBtn.center.x = loginButton.center.x 
    googleSignInBtn.center.y = loginButton.center.y + 80 
    googleSignInBtn.style = .Wide 
    self.view.addSubview(googleSignInBtn) 



func signIn(signIn: GIDSignIn!, presentViewController viewController: UIViewController!) { 
    print("Signed in with google") 
} 

func signInWillDispatch(signIn: GIDSignIn!, error: NSError!) { 
    print("Signin Will Dispatch") 
} 

func signIn(signIn: GIDSignIn!, dismissViewController viewController: UIViewController!) { 
    print("GoogleSignInDismiss") 
} 

func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) { 

    activityIndicatorBegin() // Having the activity indicator start here is too late. I need it to start as soon as the google button is pressed. Otherwise there would be a moment just after the google view dismisses without activity indicator 

    if let error = error { 
     print(error.localizedDescription) 
     return 
    } 

    let authentication = user.authentication 
    let credential = FIRGoogleAuthProvider.credentialWithIDToken(authentication.idToken, accessToken: authentication.accessToken) 

    FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in 
     if let error = error { 
      self.showErrorAlert("Error Sign in Firebase with google", message: error.localizedDescription) 
     } else { 

     } 
     self.activityIndicatorEnd() 
    } 
} 

func signIn(signIn: GIDSignIn!, didDisconnectWithUser user:GIDGoogleUser!, withError error: NSError!) { 
    // Perform any operations when the user disconnects from app here. 
    print("didDisconnectWithUser") 
} 
+0

당신의 코드를 게시 할 내가이있는 UIButton 작성했고 ... –

+0

그렇게 많이 IOS를 알고 있지만 "가이드"확인해야하지 마십시오 https://developers.google .com/identity/sign-in/ios/start-integration 및 https://developers.google.com/identity/sign-in/ios/sign-in –

+0

코드가 게시되었습니다. 내가 guid 개발자들과 내가 여기 붙어있는 곳을 통과했다. 건배 – user172902

답변

0

문제가 해결되었습니다. 위와 같이 프로그래밍 방식으로 단추를 만들어서 해결할 수 없었습니다. 단순히 다음

@IBAction func signInWithGoogleBtn(sender: AnyObject) { 
    activityIndicatorBegin() 
    GIDSignIn.sharedInstance().signIn() 
} 
관련 문제