Tuesday, April 12, 2016

Android Parse: Can't update local user

Leave a Comment

I have a custom boolean field called Approved in my custom ParseUser object. We change this field from false to true via a web app. According to the documentation, I should be able to update currentUser after changing the flag with fetchInBackground(), like this:

ParseUser.getCurrentUser().fetchInBackground(new GetCallback<ParseObject>() {     @Override     public void done(ParseObject parseObject, ParseException e) {         Log.v("qwer", "fetched User: " + ((CustomUser)parseObject).isApproved());     } }); 

But even though the approved flag has been set to true, the result coming back from the server is always false. Unless I logout and login again, at which point currentUser and the respective field is synced with the server.

Why doesn't fetchInBackground() work for the local user, and if I'm using it incorrectly, how do I update the currentUser.

1 Answers

Answers 1

Please see this link, the point is to use pinInBackground and also enable local datastore with Parse.enableLocalDatastore(yourContext); in your Application class.


Update:

Not sure if this will help you, but I do have a similar situation with you:

I do a typical user.put("userVerified", true); then user.saveInBackground to save a boolean that indicates whether user has been verified, then in the next activity I use user.getBoolean("userVerified") to retrieve the flag...Would this be something you might consider?

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment