2016-03-19 10 views

cevap

1

Gerekli yetkilendirme işlevlerini kullanmadığınız için hatayı alıyorsunuz. Bu işlevler ayrıca kullanıcı hakkında bilgi verecektir.

ardından Google aşağıdaki işlevleri uygulamak gerekir:

Uygulama Delegesi:

// [START signin_handler] 
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, 
withError error: NSError!) { 
    if (error == nil) { 
    // Perform any operations on signed in user here. 
    let userId = user.userID     // For client-side use only! 
    let idToken = user.authentication.idToken // Safe to send to the server 
    let name = user.profile.name 
    let email = user.profile.email 
    // [START_EXCLUDE] 
    NSNotificationCenter.defaultCenter().postNotificationName(
     "ToggleAuthUINotification", 
     object: nil, 
     userInfo: ["statusText": "Signed in user:\n\(name)"]) 
    // [END_EXCLUDE] 
    } else { 
    print("\(error.localizedDescription)") 
    // [START_EXCLUDE silent] 
    NSNotificationCenter.defaultCenter().postNotificationName(
     "ToggleAuthUINotification", object: nil, userInfo: nil) 
    // [END_EXCLUDE] 
    } 
} 
// [END signin_handler] 

// [START disconnect_handler] 
func signIn(signIn: GIDSignIn!, didDisconnectWithUser user:GIDGoogleUser!, 
withError error: NSError!) { 
    // Perform any operations when the user disconnects from app here. 
    // [START_EXCLUDE] 
    NSNotificationCenter.defaultCenter().postNotificationName(
     "ToggleAuthUINotification", 
     object: nil, 
     userInfo: ["statusText": "User has disconnected."]) 
    // [END_EXCLUDE] 
} 
    // [END disconnect_handler] 

View Controller:

// Implement these methods only if the GIDSignInUIDelegate is not a subclass of UIViewController. 

// Stop the UIActivityIndicatorView animation that was started when the user 
// pressed the Sign In button 
func signInWillDispatch(signIn: GIDSignIn!, error: NSError!) { 
    myActivityIndicator.stopAnimating() 
    } 

// Present a view that prompts the user to sign in with Google 
    func signIn(signIn: GIDSignIn!, 
presentViewController viewController: UIViewController!) { 
self.presentViewController(viewController, animated: true, completion: nil) 
    } 

// Dismiss the "Sign in with Google" view 
func signIn(signIn: GIDSignIn!, 
dismissViewController viewController: UIViewController!) { 
    self.dismissViewControllerAnimated(true, completion: nil) 
    } 
İlgili konular