簡體   English   中英

解析 Back4App iOS Swift “PFUser.logInWithAuthType(inBackground: apple” 方法返回任務為零

[英]Parse Back4App iOS Swift “PFUser.logInWithAuthType(inBackground: apple” method returns task as nil

我正在嘗試在我的 iOS Swift 應用程序中實現 Apple 登錄。 我已經有手動注冊和 Facebook 登錄。

我已經實現了蘋果登錄,它工作正常,因為它每次都返回TOKENUSER

但是當我在“PFUser.logInWithAuthType(inBackground: apple”方法中傳遞它時,這部分工作,有時它可以很好地處理任務返回值,而其他大部分時間 Parse 將任務返回為 nil ,錯誤“內部服務器錯誤”。

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 中得到修復,該版本目前處於私人測試版中。 您可以郵寄他們以獲得訪問權限。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM