satish123
satish123

Reputation: 541

Parse Android Anonymous ParseUser not null but objectId is null

I am using Parse to login using Facebook and also enabling Parse Anonymous User in the app. After logging out of the app, the ParseUser is not null but ParseUser.getObjectID() is returning null. The following is in onCreate() of Application.java

ParseUser.enableAutomaticUser();
ParseUser.getCurrentUser().increment("RunCount");
ParseUser.getCurrentUser().saveInBackground();

Please help.

Upvotes: 0

Views: 496

Answers (1)

Lucas Crawford
Lucas Crawford

Reputation: 3118

Reading the documentation on Parse's docs for creating a new ParseUser:

public ParseUser()

Constructs a new ParseUser with no data in it. A ParseUser constructed in this way will not have an objectId and will not persist to the database until ParseUser.signUp() is called.

So no objectId is attributed to this new ParseUser until you signUp, this means an automatic user doesn't have an objectId field (read my comment above).

To fix this, you can probably do something like:

ParseUser user = new ParseUser();
user.put("id", id);
...
...
user.saveInBackground();

since you are saving the new ParseUser to the local cache, it will have this id and is accessible. Not sure about your intentions to use the objectId, but it's always an option to create custom columns for a Parse object.

Upvotes: 1

Related Questions