Ios 谷歌在Swift中搜索获得个人资料信息

Ios 谷歌在Swift中搜索获得个人资料信息,ios,iphone,swift,google-login,Ios,Iphone,Swift,Google Login,我使用google+登录在AppDelegate中获取用户配置文件信息 如何访问viewController中的用户配置文件信息 AppDelegate代码: func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) { if (error == nil) { // Perform any operations

我使用google+登录在AppDelegate中获取用户配置文件信息

如何访问viewController中的用户配置文件信息

AppDelegate代码:

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]

            print(userId)

        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]
        }
}
I think you try this. you will get definite result 
remember to import some library

import AddressBook
import MediaPlayer
import AssetsLibrary
import CoreLocation
import CoreMotion
/
/
    //MARK: Google Login
        @IBAction func btnActionGoogleLogin(sender : UIButton)
        {
            var googleSignIn: GPPSignIn!
            googleSignIn = GPPSignIn.sharedInstance();
            googleSignIn.shouldFetchGooglePlusUser = true;
            googleSignIn.clientID = "";
            googleSignIn.shouldFetchGoogleUserEmail = true;
            googleSignIn.shouldFetchGoogleUserID = true;
            googleSignIn.scopes = [kGTLAuthScopePlusLogin];
            googleSignIn.scopes = ["profile"]
            googleSignIn.delegate = self;
            googleSignIn.authenticate();
        }

        //MARK: G+ Delegate
        func finishedWithAuth(auth: GTMOAuth2Authentication!, error: NSError!) {
            let plusService :GTLServicePlus = GTLServicePlus.init()
            plusService.retryEnabled = true
            plusService.authorizer = GPPSignIn.sharedInstance().authentication
            plusService.apiVersion = "v1"

            let query : GTLQueryPlus = GTLQueryPlus.queryForPeopleGetWithUserId("me") as! GTLQueryPlus

            plusService.executeQuery(query) { (ticket,person, error) -> Void in
                if ((error) != nil) {
                    //Handle Error
                } else {
                    NSLog("Email= %@", GPPSignIn.sharedInstance().authentication.userEmail)
                    NSLog("GoogleID=%@", person.identifier)
                    print(person)
                    print(person.displayName)
                }
            }

        }
        func didDisconnectWithError(error: NSError!) {

        }
    }