twodwarfs
twodwarfs

Reputation: 1

Parse.com unpinInBackground doesn't work

It's very simple flow that we are implementing. First pin an item:

 object.pinInBackground(new SaveCallback() {
         @Override
         public void done(ParseException e) {
                if (e == null) {
                    // success
                } else {
                    // error
                }
          }
 });

Then later on I unpin it:

object.unpinInBackground(new DeleteCallback() {
    @Override
    public void done(ParseException e) {
          mObjects.remove(object);
          mObjectsAdapter.notifyDataSetChanged();
    }
});

But! When I get to check the local datastore, like this:

ParseQuery<Object> query = ParseQuery.getQuery("Object");
query.fromLocalDatastore().findInBackground(new FindCallback<Object>() {
        @Override
        public void done(List<Object> objects, ParseException e) {
                // list of object contains the unpined object!
        }
});

The list of objects contains all unpined objects from before!

Is this something that I am doing wrong, not understand or there is some bug in Parse.com?

Upvotes: 0

Views: 188

Answers (3)

Paweł Wojtaszko
Paweł Wojtaszko

Reputation: 23

For me the answer was I invoked saveEventually(). When use saveEventually() the problem is object can't disappear until we will be online. But then object fly to server - will be not deleted.

Upvotes: 1

bahakz
bahakz

Reputation: 373

you can't unpin an object that has a referenced object

Probably you have another object which has a reference to the object you want to delete.

So you will have to delete those first.

Upvotes: 0

fear7
fear7

Reputation: 81

Going off this.

You may need to do this:

object.unpinInBackground("Object Name", new DeleteCallback() {
    public void done(ParseException e) {
        if (e == null) {
            // successful
        } 
        else {
            // unsuccessful
        }
    }
 });

You need to specify the name of the object you are trying to unpin.

Upvotes: 0

Related Questions