Ios 无法获取Facebook用户的生日,位置在Swift2中
以下是我的密码:-Ios 无法获取Facebook用户的生日,位置在Swift2中,ios,swift,facebook,Ios,Swift,Facebook,以下是我的密码:- let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager() fbLoginManager .logInWithReadPermissions(["public_profile","user_birthday","email"], handler: { (result, error) -> Void in if (error == nil) { let fbloginresu
let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
fbLoginManager .logInWithReadPermissions(["public_profile","user_birthday","email"], handler: { (result, error) -> Void in
if (error == nil)
{
let fbloginresult : FBSDKLoginManagerLoginResult = result
if(fbloginresult.grantedPermissions.contains("email"))
{
self.getFBUserData()
}
}
})
}
func getFBUserData()
{
if((FBSDKAccessToken.currentAccessToken()) != nil)
{
FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, name, first_name, last_name, picture, email, gender, age_range, birthday"]).startWithCompletionHandler({ (connection, result, error) -> Void in
if (error == nil)
{
print(result)
self.performSegueWithIdentifier("login_with_facebook_vc", sender: nil)
}
})
}
}
我是swift2的新手。因此,我无法获得facebook用户生日
,位置
请帮助我。我使用此代码获取电子邮件:
func getEmail() {
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"email"])
graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
if ((error) != nil)
{
// Process error
print("Error: \(error)")
}
else
{
print("fetched user: \(result)")
if let facebookEmail: String = result.valueForKey("email") as? String {
print("email is: \(facebookEmail)")
self.email = facebookEmail
}
}
})
}
试试这个生日礼物