1

我无法找到从谷歌获取手机号码和出生日期的解决方案....

请帮我...

 @IBAction func onGoogleClick(sender: AnyObject) {

    var googleSignIn: GIDSignIn!


    googleSignIn = GIDSignIn.sharedInstance();
    googleSignIn.delegate = self
    googleSignIn.uiDelegate = self
    googleSignIn.shouldFetchBasicProfile = true;
    googleSignIn.clientID = "75749930852-g1qaafmntbrgendjea6bmk5g8e4684ue.apps.googleusercontent.com"
    googleSignIn.scopes.append("https://www.googleapis.com/auth/plus.login")

    googleSignIn.scopes.append("https://www.googleapis.com/auth/user.birthday.read")
    googleSignIn.scopes.append("https://www.googleapis.com/auth/user.phonenumbers.read")
    googleSignIn.scopes.append("https://www.googleapis.com/auth/userinfo.profile")
    googleSignIn.scopes.append("https://www.googleapis.com/auth/userinfo.email")
    googleSignIn.signIn();
}




public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {

    if user != nil{

        if let name = user.profile.name as? String {
            self.txtFullName.text = name
        }

        if let email = user.profile.email as? String{
            self.txtEmail.text = email
        }


        if let gID = user.userID as? String {
            self.registerID = gID
            self.registerType = UserRegisterType.GOOGLE
        }
    }



}
4

0 回答 0