gpt4 book ai didi

facebook - 快速将 Facebook "name"添加到 PFUser ["fullname"]

转载 作者:行者123 更新时间:2023-11-30 10:13:28 24 4
gpt4 key购买 nike

我有一个注册/登录方法(来自 PFFacebookUtilsV4),当新的 Facebook 用户登录时,它可以成功地将新的 PFUser 对象添加到我的 Parse 数据库中。在该方法中,我创建了 FBSDKGraphRequest 来获取基本用户数据(姓名、电子邮件) )。但是,我在将名称和电子邮件添加到新创建的 PFUser 对象时遇到问题。到目前为止,这是我的代码:

@IBAction func facebookLogin(sender: AnyObject) {
PFFacebookUtils.logInInBackgroundWithReadPermissions(["public_profile","email","user_friends"], block: { (user: PFUser?, error: NSError?) -> Void in
if let user = user {
if user.isNew {
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"name,email,picture.width(480).height(480)"])
graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
if ((error) != nil)
{
println("Error: \(error)")
ProgressHUD.showError("Error occurred.")
} else {
self.userFullName = result.valueForKey("name") as? String
println("User Name is: \(self.userFullName)")
self.userEmail = result.valueForKey("email") as? String
println("User Email is: \(self.userEmail)")

// Here I try to add the retrieved Facebook data to the PFUser object
user["fullname"] = self.userFullName
user.email = self.userEmail

self.performSegueWithIdentifier("login", sender: self)
println("User signed up and logged in through Facebook!")
ProgressHUD.showSuccess("Welcome \(self.userFullName)!")
}
})

} else {
println("User logged in through Facebook!")
ProgressHUD.showSuccess("Welcome \(self.userFullName)!")
self.performSegueWithIdentifier("login", sender: self)
}
} else {
println("User cancelled the Facebook login.")
}
})
}

谢谢!非常感谢任何帮助。

最佳答案

在 Facebook 请求闭包中添加新数据后保存用户。

user.saveEventually()

或者您喜欢的任何其他保存。

关于facebook - 快速将 Facebook "name"添加到 PFUser ["fullname"],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31576544/

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