Alexander Frieden
Alexander Frieden

Reputation: 17

iOS Swift + Parse.com - user authentication best practices

I would love to know if there are some best practices out there to prevent me from future frustration when it comes to user authentication with Parse.com in Swift projects.

I have a handful of Views that would not function without a logged in user. My current methodology has been to use ViewWillAppear to redirect non-loggedin users to the login page with something as simple as

override func viewWillAppear(animated: Bool) {
    if (PFUser.currentUser() == nil) {   
         self.navigationController?.popToRootViewControllerAnimated(true)
         presentViewController(alert, animated: true, completion: nil
    } else {
        // (...code...)
}

but occasionally i get a parse 209 error : invalid session token when somehow i login a user in the iOS simulator but parse doesn't recognize that user as the current user on the server side. I'd love to know if I'm following solid conventions or just making up weird workarounds that are causing externalities.

Upvotes: 1

Views: 514

Answers (1)

Mika
Mika

Reputation: 5845

A few comments:

Upvotes: 3

Related Questions