Parse PFUser.currentUser returns nil - Swift
I discovered that this problem appeared because the segue signInToNavigation
was wired from the Login-button, instead from the login view controller itself. This resulted in the segue being executed before the login function was executed, and therefore the PFUser.currentUser()
object was not yet assigned when the table view loaded. I solved this by rewiring the segues. Stupid slip-up on my side.
Thanks to Ryan Kreager and Wain for taking time to help me figure out this issue!
iOS App Extension has PFUser currentUser set to nil
Found the problem:
I wasn't enabling local datastore in the app extension. Data store must be enabled both in the app itself and the app extension. Adding [Parse enableLocalDatastore];
before initializing Parse and after data sharing code (enableDataSharingWithApplicationGroupIdentifier:containingApplication:
) solved my problem.
To keep the current user logged in using swift and parse
That snippet of code should work as long as the session in parse is still up.
I ran into the same problem because I wrote that code inside of func viewDidLoad().
When i wrote:
func viewDidAppear(animated:Bool){
super.viewDidAppear(animated)
var currentUser = PFUser.currentUser()
if currentUser != nil {
// Do stuff with the user
} else {
// Show the signup or login screen
}
it worked perfectly fine
How to cache PFUser locally if it fails to sign up due to internet failure?
I ended up using PFUser.enableautomaticuser()
and then make changes to PFUser.currentUser()
.
At last I will attempt to signUp
, if failed, I will call saveEventually()
so that next user logs in. They will retain the previous PFUser
reference, so that their information won't be lost in case the user starts the application without internet.
Related Topics
Swiftui - Optional Timer, Reset and Recreate
How to Keep the Header Cell Moving with the Tableview Cells in Swift 2.0
Passing Data Between View Controllers Without Segue
Cannot Set Color of Button's Label Inside Menu in Swiftui
@Ibdesignable - View Not Rendering as Expected
Cocoapods, Add Dependencies to All Targets in a Generic Way
Uibutton Subclass @Ibaction Not Working
Show Bounding Box While Detecting Object Using Arkit 2
Skvideonode Only on a Small Part of Scnsphere
Recognizing Touch Events Only Inside the Masked View
Share Attachment from Mail App with Share Extension in iOS
Adding Uigesturerecognizer to Subview Programmatically in Swift
Wake Up Application in Background Using Audiosession Like Alarmy iOS App
Getting Error Ambiguous Use of Tableview(_:Numberofrowsinsection:)