Can't delete ParseObject with owner account - android

I'm trying to delete a parse object with the following method:
object.deleteInBackground(new DeleteCallback() {
#Override
public void done(ParseException e) {
if(e !=null) {
Log.e("Parse: ",e.toString());
}
}
});
Console Output
E/Parse:: com.parse.ParseRequest$ParseRequestException: Object not
found.
My object's ACL is public read and owner read & write and I am connected to the owner account.
The strange thing is that I actually can delete the object if it has public write ACL, but I only want the owner have the possibility to delete it.
Has anyone encountered similar issues ?

Okay, I've figured out that I did something else wrong with my user login which caused this error. Anyways thanks to anybody who tried to help me

Related

"Cannot save a ParseUser that is not authenticated" with authenticated user

I'm using Parse as my backend and I'm trying to "like" a post that another user posted on the app. I'm querying to get the post, then incrementing the number of likes by 1, then adding the current user's object ID to an array that holds all the ID's of users which liked the post.
carLikeQuery.getInBackground(carItem.getObjectId(), new GetCallback<ParseObject>() {
#Override
public void done(ParseObject object, ParseException e) {
object.increment("likes");
object.addUnique("usersWhoLike", ParseUser.getCurrentUser().getObjectId());
object.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if(e==null) {
Log.d("SAVE", "Like saved :)");
} else {
Log.e("SAVE", "Not saved :( :" + e.getLocalizedMessage());
}
}
});
}
});
The error I'm getting:
E/SAVE: Not saved :( :java.lang.IllegalArgumentException: Cannot save a ParseUser that is not authenticated.
I saw the source code for the ParseUser from somewhere:
void validateSave() {
if (getObjectId() == null) {
throw new IllegalArgumentException("Cannot save a ParseUser until it has been signed up. Call signUp first.");
}
if (!isAuthenticated() && isDirty()) {
throw new IllegalArgumentException("Cannot save a ParseUser that is not authenticated.");
}
}
Doing the same kind of checking in my code reveals that the the currentUser is AUTHENTICATED and NOT DIRTY.
What could the issue be? To be honest, I want to say that it was working just fine before today, but obviously I was changing something and made a mistake down the line and I can't find it! Any help would be greatly appreciated.
I resolved the issue by creating an entirely new Parse application with the same data structure/layout. It just plain worked without any code changes.
You can follow the issue on GitHub here

ParseObject with pointer to another ParseUser fails due to "ParseUser that is not authenticated"

I have project where I send messages between 2 and 2 ParseUsers, and save the messages as a ParseObjects where I keep a Pointer to the 2 users sending messages to each other. The code works for every user in the database except when I send a message to 1 particular user. Then I get "Cannot save a ParseUser that is not authenticated", so it seems like Parse tries to save the other User object, together with saving my message ParseObject, just with this one particular user.
Tried to create a "Save without data" object, but get the same error. Anyone experienced this before?
ParseObject message = new ParseObject("MSG");
message.put("sender", meUser);
message.put("receiver", otherUser);
message.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if( e== null){
Log.i(TAG, " Worked...");
}else {
e.printStackTrace();
}
}
});
The problem was that I actually did try to to change another users object. I found out where by backtracking using the "isDirty()" method on the object that was giving me issues to find out where I was making changes on the object. This method lead me to the root of the problem.
isDirty() returns true if you have made any changes to an object but not saved it yet.

ParseQuery gives 0 objects when querying from local datastore even after successfully pinning

I am using the Android SDK of parse.com and have arrived at a peculiar problem.
From a fragment's onCreate:
Fetch an object from the server.
Pin it.
Fetch an object from the local datastore.
Here is a snippet of the code from the onCreate:
ParseObject myChatGroup = ParseObject.createWithoutData("ChatGroup", "mOJGWRiLPC");
myChatGroup.fetchInBackground(new GetCallback<ParseObject>() {
#Override
public void done(ParseObject chatGroup1, ParseException e) {
if (e == null) {
l.d("Fetched chat group: " + chatGroup1 + " from server");
chatGroup1.pinInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
l.d("Successfully pinned chat group");
ParseQuery<ParseObject> chatGroupParseQuery = new ParseQuery<>("ChatGroup");
chatGroupParseQuery.fromLocalDatastore()
.findInBackground(new FindCallback<ParseObject>() {
#Override
public void done(List<ParseObject> list, ParseException e) {
if (e == null) {
l.d("Found " + list.size() + " chat groups from local datastore");
} else {
e.printStackTrace();
}
}
});
} else {
e.printStackTrace();
}
}
});
} else {
e.printStackTrace();
}
}
});
Here is the log:
Fetched chat group: ChatGroup { objectId: mOJGWRiLPC, name: Admin } from server
Successfully pinned chat group
Found 0 chat groups from local datastore
But this doesn't make any sense! I just pinned an object so how can there be 0 objects in the local datastore. The code is so simple. What am I doing wrong? Could it be a bug with the SDK?
Any insight will be much appreciated I have been trying to find the issue for days now.
The Parse setup looks fine to me:
ParseObject.registerSubclass(ChatGroup.class);
Parse.enableLocalDatastore(this);
Parse.initialize(this, AppProps.properties.appId,
AppProps.properties.clientKey);
ParseUser.enableRevocableSessionInBackground();
Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG);
Note:
It works fine when trying the same logic with the ParseUser object. And even other classes of mine like my Message which leads me to suspect that something is wrong with my ChatGroup class.
I have added two fields to my ChatGroup class on the parse.com data browser: name(String) and messages(Relation) with read and wrote access to a role called Admin.
When browsing to the actual parse db (using root access) I find that the database table (ParseObjects) does contain the row that I pinned. But somehow parse shows 0 results on querying it!
Parse doesn't seem to support ACLs on local datastore. So the easiest way to get around this issue is to do ignoreACLs() on the query -- assuming you do have roles/acls setup correctly on the server side, so whatever you have pinned locally should be OK permission-wise already.
I found the issue. It seems to be more like a bug with the Android SDK of parse. I narrowed it down to an issue with retrieving pinned objects with special ACLs using the Android SDK.
Initially, the object had the ACL such that only the role 'Admin' (that I created) can read and write. The funny thing is that the user with which I was testing the pinning and querying was an 'Admin'! But, when I changed the ACL such that public can read but only Admin can write, the problem was resolved!
My theory was that querying the local datastore behaves like a public query, no matter what role the user that is making the query has! But if any other theory explaining this would be appreciated. Luckily, in my case I need public read access, but this bug can be a huge downfall for some who need to have read access restricting ACLs! Hopefully parse.com will fix this issue soon.
This is quite a big issue! I am surprised that I couldn't find a question regarding this issue.
Yeah so basically you have to set ACL for current user and pin it before you pin the chat group.
ParseACL acl = new ParseACL();
acl.setReadAccess(ParseUser.getCurrentUser(), true);
ParseUser.getCurrentUser().setACL(acl);
ParseUser.getCurrentUser().pinInBackground();

Parse.com android - disable push notifications

I've started using parse.com to receive push notifications in my application.
It works perfectly, but I have a couple of questions.
We perform registration, but unused channels, as follows:
ParsePush.subscribeInBackground("", new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Log.d("dmode", "Oks!");
} else {
Log.e("dmode", "Fail :(", e);
}
}
});
My first question is:
I find no way to disable receiving push notifications
I searched the official documentation and stackoverflow, but I find solutions that do not work for me.
I tried:
ParsePush.unsubscribeInBackground("", new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Log.d("dmode", "unsuscribe oks");
} else {
Log.e("dmode", "unsuscribe fail", e);
}
}
});
Unsuccessfully, I have also tried:
ParsePush.unsubscribeInBackground("");
...but not work.
I'm not using channels, that is why the quotes are empty:
ParsePush.subscribeInBackground("", new SaveCallback() { //...
How I can enable and disable push notifications?
The second query is that sometimes receive duplicate notifications until two three times at once on the same device.
Someone has been the same?
Thank you very much for the help.
Greetings!
I think you should use a name for a default channel even if you are not using channels and not the empty string "".
Also have a look here Parse Question
I quote from the answer on the above link
If you called PushService.setDefaultCallback, call it again passing null as the class.

ParseUser.setEmail() does not work with "some kind of Strings"?

I'm trying to set the email in a user obtained from Facebook SDK. If I set the email with any string like this:
user.setEmail("whatever#whwhwh.com");
user.saveInBackground();
It works, no problem... it appears in Parse's Data Browser...
If I try to do what I need to do(see code below), then it doesn't work, I've checked the String value and it's ok, it is the needed email....I've tried different things.. no luck.. Please help, thanks.
user.setEmail(user.getProperty("email").toString());
user.saveInBackground();
Make sure the email being supplied is not used by any other user. This is because an email must be unique.
When calling saveInBackground, it will actually not throw any exception if one does occur. So in your case, if the email is a duplicate, the email won't get saved and no exception is thrown.
To catch an exception with saveInBackground, you can use the SaveCallback.
user.saveInBackground(new SaveCallback() {
public void done(ParseException e) {
if (e == null) {
// No exception
} else {
// Exception occured
}
}
});
For a list of exceptions you can refer to ParseException.

Categories

Resources