Parse Back4App iOS Swift "PFUser.logInWithAuthType(inBackground: apple" 方法将任务返回为 nil



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

我已经实现了apple登录,它运行良好,因为它每次都返回TOKENUSER

但是,当我在"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版本中修复,该版本目前处于私有测试版。您可以通过邮件获取访问权限。

相关内容

最新更新