Hi
I am experiencing an issue when I use Login With Apple feature.
I have deleted all objects on User table (I was testing user data migration from iCloud to backendless) and after that I receive:
Error: Not existing user token - B1C0F354-D8BA-4F55-AFA7-F91D4D906034. Relogin user to update your user token
when I execute the following code:
private func signInWithExistingAccount(credential: ASAuthorizationAppleIDCredential) {
if let identityToken = credential.identityToken,
let tokenString = String(data: identityToken, encoding: .utf8) {
AppleAuth.shared.login(token: tokenString, responseHandler: { loggedInUser in
Backendless.shared.userService.currentUser = (loggedInUser as! BackendlessUser)
self.signInSucceeded(.success(credential.user))
}, errorHandler: { fault in
print("Error: \(fault.message ?? "")")
self.signInSucceeded(.failure(fault))
})
} else { self.signInSucceeded(.failure(ErroresCK.notSignediCloud))}
}
Any idea how I can manage this?
Thank you
PS here the class called above:
class AppleAuth: NSObject {
static let shared = AppleAuth()
private let serviceName = "AppleAuth"
func login(token: String, responseHandler: ((Any?) -> Void)!, errorHandler: ((Fault) -> Void)!) {
let parameters = token
Backendless.shared.customService.invoke(serviceName: serviceName, method: "login", parameters: parameters, responseHandler: responseHandler, errorHandler: errorHandler)
}
}