@IBAction func facebookLoginbuttonPressed(_ sender: FBSDKLoginButton) {
let facebookLogin = FBSDKLoginManager()
facebookLogin.logInWithReadPermissions(["email"], fromViewController: self) { (facebookResult: FBSDKLoginManagerLoginResult!, facebookError: NSError!) -> Void in
print("Facebook login failed. Error \(facebookError)")
} as! FBSDKLoginManager
}
I am getting error like "Cannot convert value of type '(FBSDKLoginManagerLoginResult!, NSError!) -> Void' to expected argument type 'FBSDKLoginManagerRequestTokenHandler!'". Please help me to solve this?
@IBAction func selectFacebookLogin(sender: UIButton)
{
let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
fbLoginManager.logInWithReadPermissions(["public_profile", "email", "user_friends"], fromViewController: self)
{
(result, error) -> Void in
if (error == nil)
{
let fbloginresult : FBSDKLoginManagerLoginResult = result
if result.isCancelled
{
return
}
if(fbloginresult.grantedPermissions.contains("email"))
{
self.getFBUserData()
}
}
}
}
func getFBUserData()
{
showIndicator()
if((FBSDKAccessToken.currentAccessToken()) != nil)
{
FBSDKGraphRequest(graphPath: "me",
parameters: ["fields": "id, name, first_name, last_name, picture.type(large), email , gender"]).startWithCompletionHandler(
{ (connection, result, error) -> Void in
self.hideIndicator()
if (error == nil)
{
print(result)
}
})
}
}