하면 사용자 정의 GoogleManager
에 대해 하나의 대리자를 만들고 그 GoogleManager
내부 대리자의 인스턴스를 생성하고 그 후, 당신은 사용자 정의 클래스 GoogleManager
의 인스턴스를 생성하는 클래스가 대리자를 구현할 때 사용자 정의 위임 사용이라고 GIDSignInDelegate
방법이라고 불리는 방법. 그래서 이런 식으로 보일 것입니다.
protocol GoogleManagerDelegate {
func receiveResponse(user: GIDGoogleUser)// Pass Parameter that you want
}
은 이제 GIDSignInDelegate
방법에 응답을 얻을 GoogleManager
수업 시간에 당신은 GoogleManagerDelegate
메소드를 호출 할 필요가있다.
class GoogleManager {
var delegate: GoogleManagerDelegate?
//Your other method
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
self.delegate?.receiveResponse(user: user)
}
}
는 이제 생성
GoogleManager
의 인스턴스와 자기에의 위임 인스턴스를 설정 컨트롤러 내부의
GoogleManagerDelegate
를 구현합니다.
class ViewController: UIViewController, GoogleManagerDelegate {
//Your other methods
func googleSignIn() {
let googleManager = GoogleManager()
googleManager.delegate = self
}
//GoogleManagerDelegate method
func receiveResponse(user: GIDGoogleUser) {
//Access user object here
}
}
Google SDK의 완료 처리기와 관련된 방법이 없습니다. –
NotificationObserver를 추가 할 수 있습니다. – Wolverine