I have a single view application that utilizes Parse to create a PFLogInViewController. Before the BeaconViewController can be accessed, the user must authenticate with Facebook - this is working fine. My issue is with the logout portion - after the user's session is destroyed, I need the PFLogInViewController
to reappear. I tried to accomplish this by popping to the RootViewController
, but this is not resolving the issue.
I referenced this thread as well as this one, but again did not have any luck.
Here is BeaconViewController.m
with the authentication and logout logic
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
FBRequest *request = [FBRequest requestForMe];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
[self dismissViewControllerAnimated:YES completion:nil];
[self pictureRequest];
}
else if (error) {
NSLog(@"facebook session was invalid");
[self logoutButtonAction:nil];
PFLogInViewController *login = [[PFLogInViewController alloc] init];
login.fields = PFLogInFieldsFacebook;
login.delegate = self;
NSArray *permissionsArray = @[ @"user_about_me", @"user_relationships", @"user_birthday", @"user_location"];
login.facebookPermissions = permissionsArray;
[self presentViewController:login animated:YES completion:nil];
}
else {
NSLog(@"Some other error: %@", error);
}
}];
}
- (IBAction)logoutButtonAction:(id)sender {
[PFUser logOut];
[self.navigationController popToRootViewControllerAnimated:YES];
}