我很快就是新人。任何人都可以告诉我如何从Facebook获取电话号码字段。
按下按钮:
@IBAction func fbButtonAct(_ sender: Any) {
view.endEditing(true)
let fbLogin : FBSDKLoginManager = FBSDKLoginManager()
let loadingOverlay = loadingOnScreen(self.view.frame)
self.view.addSubview(loadingOverlay)
fbLogin.logIn(withReadPermissions: ["email"], from: self) { (result, err) in
if(err != nil){
print("custom fb login failed",err)
loadingOverlay.removeFromSuperview()
return
}
if (result?.isCancelled)!{
loadingOverlay.removeFromSuperview()
return
}
self.dataGettingFromFB(fbLogin, loadingOverlay: loadingOverlay)
print(result?.token.tokenString)
}
}
func dataGettingFromFB(_ fbLogin:FBSDKLoginManager, loadingOverlay: UIView){
FBSDKGraphRequest(graphPath: "/me", parameters: ["fields":"id, email, first_name, last_name, picture.type(large), gender, phone"]).start { (connection, result, err) in
if (err != nil){
print("failed to start graph request:",err)
loadingOverlay.removeFromSuperview()
return
}
let fbDetails = result as! NSDictionary
var email : String? = fbDetails["email"] as? String
if(email == nil){
email = ""
}
let firstName = fbDetails["first_name"] as! String
let id = fbDetails["id"] as! String
let lastName = fbDetails["last_name"] as! String
fbLogin.logOut()
}
}
答案 0 :(得分:-1)
试试这个:将public_profile置于读取权限
fbLogin.logIn(withReadPermissions:[" email"," public_profile"],from:self)