@IBAction func buttTapped(_ sender: Any) {
func facebookLogin(){
let loginManager = LoginManager()
loginManager.logIn(permissions: ["publicProfile", "email"], from: self) { loginResult in
switch loginResult {
case .failed(let error):
print(error)
case .cancelled:
print("User cancelled login.")
case .success(let grantedPermissions, let declinedPermissions, let accessToken):
print("Logged in!")
self.fetchUserProfile()
}
}
}
}//
这是下面的fetchuserprofile函数
func fetchUserProfile() {
let graphRequest : GraphRequest = GraphRequest(graphPath: "me", parameters: ["fields":"id, email, name, picture.width(480).height(480)"])
graphRequest.start(completionHandler: { (connection, result, error) -> Void in
if ((error) != nil)
{
print("Error took place: \(error ?? "" as! Error)")
}
else
{
let result = result as! Dictionary<String, Any>
let picture = result["picture"] as! Dictionary<String, Any>
let dataObj = picture["data"] as! Dictionary<String,Any>
var emailValue = result["email"] as! String?
if emailValue == nil {
emailValue = ""
}
let name = result["name"] as? String
let id = result["id"] as? String
let imageUrl = result["url"] as? String
// Update data to firestore
}
})
}
im错误,例如无法将类型'(_)->()'的值转换为预期的参数类型'LoginManagerLoginResultBlock?' (aka'可选()>')
并且,如果我尝试解决此问题,那么它会告诉我未找到案例,这里的图像是我要尝试以下的操作,即获取一些用户信息并将其上传到Cloud Firestore,任何帮助信息都将有所帮助
尝试此解决方案,这对我很有效。