将 Back4App iOS Swift "PFUser.logInWithAuthType(inBackground: apple" 方法 returns 任务解析为 nil

Parse Back4App iOS Swift "PFUser.logInWithAuthType(inBackground: apple" method returns task as nil

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

我已经实现了 apple 登录,它工作正常,因为它每次 returns TOKENUSER

但是当我在 "PFUser.logInWithAuthType(inBackground: apple" 方法中传递它时,这部分起作用,有时它与 任务返回值 一起工作得很好和其他大部分时间将 returns task 解析为 nil,错误 "internal server error"。

Parse返回的错误信息是"internal server error",在Parse中解释为Error without a message。我不认为代码一定有问题,因为它部分时间工作,或者如果我这边有问题,它应该返回错误消息。

我仍然不确定我这样做是否正确,请告诉我。提前致谢,


@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 阶段。您可以邮寄它们以获得访问权限。