gpt4 book ai didi

ios - 我如何在 iOS swift 中对我的自定义 FBSDK 登录按钮进行操作

转载 作者:行者123 更新时间:2023-11-28 08:17:33 24 4
gpt4 key购买 nike

@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)

}
})
}
}

关于ios - 我如何在 iOS swift 中对我的自定义 FBSDK 登录按钮进行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42202214/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com