PFLogInViewController error - unable to login to Facebook after exiting Parse mode

I am using PFLogInViewController for facebook login which works successfully the first time -

- (void)logInViewController:(PFLogInViewController *)controller
           didLogInUser:(PFUser *)user {
if([PFFacebookUtils isLinkedWithUser:user]){
    FBRequest *request = [FBRequest requestForMe];
    [request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
        NSDictionary *userData = (NSDictionary *)result;

        NSString *facebookID = userData[@"id"];
        NSString *name = userData[@"name"];
        NSString *location = userData[@"location"][@"name"];
        NSString *gender = userData[@"gender"];
        NSString *birthday = userData[@"birthday"];
        NSString *relationship = userData[@"relationship_status"];

        [user setObject:userData[@"id"] forKey:@"fbId"];
        [user setObject:userData[@"name"] forKey:@"name"];
        [user setObject:userData[@"email"] forKey:@"email"];
        [user saveInBackground];
        NSURL *pictureURL = [NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?type=large&return_ssl_resources=1", facebookID]];
        NSURLRequest *urlRequest = [NSURLRequest requestWithURL:pictureURL];

        // Run network request asynchronously
        [NSURLConnection sendAsynchronousRequest:urlRequest
                                           queue:[NSOperationQueue mainQueue]
                               completionHandler:
         ^(NSURLResponse *response, NSData *data, NSError *connectionError) {
             if (connectionError == nil && data != nil) {
                 // Set the image in the header imageView
                 PFFile *profileImage=[PFFile fileWithData:data];
                 [user setObject:profileImage forKey:@"profileImage"];
                 [user saveInBackground];
             }
         }];

    }];
}

[self dismissViewControllerAnimated:YES completion:nil];

      

}

If I then call [PFUser logOut] and reopen PFLogInViewController, when I touch the facebook icon to login again, the facebook spinner spins endlessly and I get the error "Attempting to change objectId to one already known to OfflineStore."

How do I log out of the current user and then log back in with the PFLogInViewController?

0


source to share


3 answers


If I remove [Parse enableLocalDatastore]

from appDelegate I don't get this error anymore. If I am not pinning any objects, are there any drawbacks to disable this? Will I be able to use "saveEventually" if there is no network connection?



+1


source


I think you are trying to store the same object (email) again.

The first time you log in, this email ID will be saved over time. But after logging out, you try to keep the same email address again.



Try searching for this entry in Parse. If you want to update other user data, you can update it with objectId.

0


source


Try disabling PFUser from PFFacebookUtils and also close your active Facebook session and clear it.

[[FBsession activeSession]closeAndClearTokenInformation];

      

Hope it helps.

0


source







All Articles