gpt4 book ai didi

ios - 解析Back4App iOS Swift“PFUser.logInWithAuthType(inBackground:苹果”)方法将任务返回为nil

转载 作者:行者123 更新时间:2023-12-01 19:33:15 27 4
gpt4 key购买 nike

我正在尝试在我的iOS Swift应用中实现Apple Login。我已经有手动注册和Facebook登录。

我已经实现了Apple登录,并且每次都返回 TOKEN USER 时,效果很好。

但是,当我在“PFUser.logInWithAuthType(inBackground:apple”)方法中传递该方法时,此方法可以部分工作,有时它可以与任务返回值一起使用,并且在大多数情况下Parse会将任务返回为nil ,错误为“内部服务器错误”。

由Parse返回的错误消息是“内部服务器错误” ,在Parse中解释为错误而没有消息。我不认为代码一定存在问题,因为它可以部分工作,或者如果我这边出了问题,它应该返回错误消息。

不过,我不确定我是否正确执行此操作,请告诉我。提前致谢,


@available(iOS 13.0, *)
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
switch authorization.credential {

case let credentials as ASAuthorizationAppleIDCredential:

let token = credentials.identityToken!
let tokenString = String(data: token, encoding: .utf8)!
let user = credentials.user

print("TOKEN: \(tokenString)")
print("USER: \(user)")

if let _ = credentials.email, let _ = credentials.fullName {
track("Register New Account")
PFUser.logInWithAuthType(inBackground: "apple", authData: ["token":tokenString, "id": user]).continueWith { task -> Any? in
if ((task.error) != nil){
DispatchQueue.main.async {
self.hideHUD()
alert("Could not login.\nPlease try again.")
track("Error with parse login after SIWA: \(task.error!.localizedDescription)")
}
return task
}
self.fillAppleDetails(userObject: task.result!, credentials: credentials)
return nil
}
} else {
track("SignIn with Existing Account")
PFUser.logInWithAuthType(inBackground: "apple", authData: ["token":tokenString, "id": user]).continueWith { task -> Any? in
if ((task.error) != nil) {
DispatchQueue.main.async {
self.hideHUD()
alert("Could not login.\nPlease try again.")
track("Error with parse login after SIWA: \(task.error!.localizedDescription)")
}
return task
}

let userObject = task.result

if userObject!.email == nil {
self.fillAppleDetails(userObject: task.result!, credentials: credentials)
} else {
DispatchQueue.main.async {
mustRefresh = true
self.navigationController?.popToRootViewController(animated: true)
self.delegate?.capital()
}
}

return nil
}
}
break

default: break
}
}

最佳答案

这是Parse Back4App方面的错误。它已在Parse版本4.2.0中修复,该版本当前在Private Beta中。您可以邮寄给他们以获得访问权限。

关于ios - 解析Back4App iOS Swift“PFUser.logInWithAuthType(inBackground:苹果”)方法将任务返回为nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61172324/

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