1

In the viewDidLoad() of the Initial View Controller in my app I run this:

let currentUser = PFUser.current()

        if currentUser != nil{

        self.performSegue(withIdentifier: "toTabs", sender: self)
    }

currentUser is always nil.

I run PFUser.enableAutomaticUser() in the AppDelegate.Swift after I configure the parse client as per the latest parse server Ios SDK. This should make it so that when ever a user is logged in they stay logged in unless a logout command is run. I have no idea why this isn't happening.

Bilal
  • 18,478
  • 8
  • 57
  • 72
Zekep
  • 41
  • 7

3 Answers3

1

After much debugging, I realized that PFUser.enableAutomaticUser() was functioning normally. The problem was that the self.performSegue(withIdentifier: "toTabs", sender: self) wasn't dispatched to the main queue. I fixed this by changing my code to:

 let currentUser = PFUser.current()

    if currentUser?.username != nil{

        print(currentUser!)

        DispatchQueue.main.async(){

        self.performSegue(withIdentifier: "toTabs", sender: self)

        }

    }else{

        print("No current User")
  }

Thanks, to all of you for your help, and I'm sorry to have wasted your time with this.

Zekep
  • 41
  • 7
0

I had the same problem running Parse version 2.2 (or older, not sure), where did you call the PFUser.enableAutomaticUser()?, I solved it by calling it right after the ApplicationID was made:

Parse.setApplicationId(parseApplicationID, clientKey:parseClientKey)
PFUser.enableAutomaticUser()
Enrique
  • 293
  • 1
  • 2
  • 15
0

I enable keychain sharing, clean, delete the app, and reinstall to get things to work properly.

Here are steps to enable keychain.

Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56