3

When you sign in using Parse, [PFUser currentUser] is cached locally on the device. I have a problem in that some custom data stored in that user's object can be updated outside of the app, so if the user is still logged in calling [PFUser currentUser] will get the cached user object and therefore it won't have the new data. To update the cached user's object, the user has to sign out and back in.

How can I update/refetch the current user programmatically without discarding their session?

Jordan H
  • 52,571
  • 37
  • 201
  • 351

1 Answers1

6

Yes, it did have method to deal with this issue from Parse.com. You can check the category of fetch method like - (BFTask *)fetchInBackground and here is the link for API: https://parse.com/docs/ios/api/Classes/PFObject.html#//api/name/fetchInBackground

Lucas Huang
  • 3,998
  • 3
  • 20
  • 29
  • 2
    Did you try to call `[[PFUser currentUser] fetch];`? – Lucas Huang Jul 16 '15 at 18:20
  • Note that `[[PFUser currentUser] fetch];` will make a `synchronous` call to the Parse server. From the Parse [docs](https://parse.com/docs/ios/api/Categories/PFObject%28Synchronous%29.html) on the `PFObject+Synchronous` category: This category lists all methods of `PFObject` class that are synchronous, but have asynchronous counterpart, Calling one of these synchronous methods could potentially block the current thread for a large amount of time, since it might be fetching from network or saving/loading data from disk. – JaredH Jan 26 '16 at 19:02
  • Will this call updates the receiver, which is `PFUser currentUser` to the most updated version? Or do we have to somehow change the `currentUser` explicitly using the `PFObjectResultBlock` and assign a new value for it? – Kesong Xie May 18 '17 at 20:02