Directly from the documentation, he says that:
PFUser # currentUser () gets the registered user from disk and returns an instance of it.
Thatโs good and thatโs it, but what if the user registered on the @ drive is not the user who is logged on to the server. Assume that the user account was deleted for some reason or the session is no longer valid due to changes in the database. I am currently facing issues.
In all the tutorials that I read, I saw the use of the following line of code as a way to check if the user is really valid, and therefore, you can skip the step of entering the application:
if let user = PFUser.currentUser() as? Subclass {
However, this creates a problem for me, as a successful login is simulated, but the login was not successful. Here is the error I'm dealing with:
[Error]: invalid session token (code: 209, version: 1.12.0)
So, the first thing I did was try to register the user, but it fails (I suppose because the user was not logged in to start), and now I am thrown into an application that immediately crashes because there is no required data by the server . This is how I tried to handle error code 209:
let query = PFQuery(className: "Foo") query.whereKey("Bar", equalTo: "Foo") query.findObjectsInBackgroundWithBlock { (foo, error) -> Void in if let error = error { print(error); if error.code == 209 { PFUser.logOutInBackgroundWithBlock { (error) -> Void in if let error = error { print("Okay, I'm trapped!"); } } } } }
The result of this "query" is as follows:
[Error]: invalid session token (Code: 209, Version: 1.12.0) Okay, I'm trapped!
I have no ideas, and I tore my hair, trying to figure out how to properly verify the user when the application starts. It seems redundant to catch an error code 209 for each request, but if this is what you need to do, then this is what you need to do.