84335

PFLogInViewController error- unable to login to Facebook after logging out with Parse

Question:

I am using PFLogInViewController to login to facebook 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 open the PFLogInViewController again, when I tap the facebook icon to log in again, the facebook spinner spins indefinitely and I get the error "Attempted to change an objectId to one that's already known to the OfflineStore."

How do I log out of the current user and then login again using PFLogInViewController?

Answer1:

If I remove [Parse enableLocalDatastore] from the appDelegate, I no longer get this error. If I am not pinning any objects is there any disadvantage to disabling this? Will I still be able to use "saveEventually" if there is no network connection?

Answer2:

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

On first login, that email id will be stored fisrt time. But, after logout, you are again trying to store same email.

Try to search that entry is already exists in Parse. If you want to update the other details of user then you can update that using objectId.

Answer3:

Try unlinking the PFUser from the PFFacebookUtils and also close the active Facebook session and clear it's token.

[[FBsession activeSession]closeAndClearTokenInformation];

Hope this helps..

Recommend

  • branch.io redirects to empty content in app, if app is not running in background
  • Bitmap.decodeStream returns null on specific existing (And working) images
  • Xml Parsing using jquery not working in IE
  • PHP/JSON-jquery pagination
  • Accessing Nested NSDictionary values in Swift 3.0
  • Badge value on “More” tab
  • NSURLConnection delegate methods not being called
  • CMCalibratedMagneticField doesn't update
  • finding the download size of a URL (Content-Length)
  • NSURL Always Returns Nil
  • Upload file onto Server from the IPhone using ASIHTTPRequest
  • Display Local HTML file from documents directory in a UIWebView on iPhone
  • HTTP status code = 0 (iPhone) (objective c)
  • Error getting audio input device sample rate: '!obj'
  • How to implement AVAudioPlayer Inside Singleton Method?
  • adding zeros in objective-c string formats
  • Error Domain=NSCocoaErrorDomain Code=3840 “Invalid value around character 0.” UserInfo={NSDebugDescr
  • Is Bolts framework[Parse+Facebook] need to use parse webservice?
  • Google App Indexing not resolving for Swift?
  • simple way to map a json collection response into swift object class
  • Facebook Friend Request - Error - 'All users in param ids must have accepted TOS'
  • K Shortest Path Python Not Working
  • Rely on Facebook user id as a permanent user identifier
  • How do i disable a text box within an iframe
  • write text on image and show it to a imageview
  • How to add learning rate to summaries?
  • Certain Arabic text gets incorrectly shown while other Arabic text gets showed normally?
  • How to change placeholder text in an autocomplete activity of android google place?
  • Double dispatch in Java example
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • RectangularRangeIndicator format like triangular using dojo
  • Cross-Platform Protobuf Serialization
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • Revoking OAuth Access Token Results in 404 Not Found
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do I configure my settings file to work with unit tests?
  • Setting background image for body element in xhtml (for different monitors and resolutions)
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Binding checkboxes to object values in AngularJs