Hello!
Can someone please point me to a guide on authenticating Parse Cloud Swift functions with the new ParseSwift library?
I did a sample project aka POC (trying to migrate a huge project with the old Objc Parse library in it)
I am doing the authentication (in AppDelegate.swift, in didFinishLaunching) with
User.login(username: "myemail", password: "123456") { result in
print("result : \(result)")
}
and in the viewDidLoad call of the root view controller I am calling a cloud function, but getting error:
ParseError code=209 error=Invalid session token
If I wait for it for 0.8 seconds though, it works. (Anything lower than 0.8 seconds fails with the same error)
struct GetUserEventsReponse: Decodable {
let userEvents: [UserEvent]
}
struct GetUserEvents: ParseCloud {
typealias ReturnType = GetUserEventsReponse
var functionJobName: String
init() {
functionJobName = "getUserEvents1"
}
}
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.8) {
let getUserEvents = GetUserEvents()
getUserEvents.runFunction() { [weak self] result in
guard let self = self else { return }
self.isRefreshing = false
switch result {
case .success(let value):
self.handleResults(value.userEvents)
case .failure(let error):
print("error fetching events : \(error)")
self.handleResults(error: error)
}
}
}
Am I missing anything? Do I need to manually add the session token in the headers or something?