I am working on a tutorial I found online with Parse. In the video, they use the parse login, if the user is not logged in, it automatically pops up the parse login, and then you are able to sign in and sign up.
Parse is a database to store information. (Just thought this should be noted)
I have created both the custom login, and signup, and linked with parse, so when I check online in the database, the users appear in there. Now I want to redirect the users after they have logged in, or signed up, but I'm having trouble with that.
In the video, they use these lines to use the parse log in:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if (PFUser.currentUser() == nil){
var loginViewController = PFLoginViewController()
loginViewController.delegate = self
var signUpViewController = PFSignUpViewController()
signUpViewController.delegate = self
loginViewController.signUpViewController = signUpViewController
self.presentViewController(loginViewController, animated: true, completion: nil)
}
}
So I tried that, and tried to modify it to work with my custom login, but I cannot get it to work, the screen just goes black.
I just want to note that: I have 2 navigation controllers. 1 for the login/signup and another for the home screen of the app.
The classes that I'm using are: ViewController (main screen) where you can choose whether to login, or signup, and this is the screen I would like to redirect if user is not logged in. This class has two buttons, login and sign up.
CustomViewLoginViewController that is the screen it goes after you press the login button.
CustomSignUpViewController that is the screen it goes after you press the signup button.
So basically if the user is not logged in, pop the ViewController so that the user has the option to login or sign up, and whether they sign up, or log in, go back to home screen.
Any help would be great.
Here's my part of my login class:
if (user != nil) {
self.dismissViewControllerAnimated(true, completion: nil)
var alert = UIAlertView(title: "Success", message: "Signed in succesfully!", delegate: self, cancelButtonTitle: "Continue")
alert.show()
} else {
var alert = UIAlertView(title: "Error", message: "\(error)", delegate: self, cancelButtonTitle: "Ok")
alert.show()
}
Edit: I managed to go back to the home screen after logging in by using:
let homeScreen = self.storyboard!.instantiateViewControllerWithIdentifier("homeScreen") as! TimelineTableViewController
self.navigationController!.pushViewController(homeScreen, animated: true)
but now it doesn't completely load the Home screen, and my Xcode says it cannot update missing constraints /: