After calling code below for several times(5-10 times), done() method for SaveCallback doesn't fire and whole application seems to stuck. It seems that this request ruins request queue and all further queries doesn't fire their callbacks either. No errors in callbacks and in logs. " BEFORE SAVING" - displayed in logs, while " SAVED" - didn't.
Do I need to change parse pricing contract, or to change my code somehow?
Log.d("MESSAGE OBJECT", " BEFORE SAVING");
messageParseObject.saveInBackground(new SaveCallback() {
#Override
public void done(final ParseException e) {
Log.d("MESSAGE OBJECT", " SAVED");
if (e != null){
completitionCallback.error(e);
return;
}
chatObject.put(ModelConstants.LAST_MESSAGE_KEY, messageParseObject);
chatObject.getRelation(ModelConstants.MESSAGES_KEY).add(messageParseObject);
chatObject.saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
Log.d("CHAT OBJECT", " SAVED");
if (e == null)
completitionCallback.success();
else
completitionCallback.error(e);
}
});
}
});
Faced this and really drove me crazy. This is what I found. If the Class is already created in Parse.com, even if there is a small discrepancy saveInBackground and saveEventually fails without any error.
Best way, if this happens is to delete the created class in Parse.com and let the android SDK call it it automatically in the first invocation.
At least that did the trick for me.
Related
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
I'm trying to update 1000 items each time with some value in specific column in my DB
ParseQuery<ParseObject> searchQuery = ParseQuery.getQuery("PhoneBook");
searchQuery.whereDoesNotExist("search");
searchQuery.setLimit(1000);
public void done(List<ParseObject> results, ParseException e) {
if (e == null) {
for(ParseObject contact:results){
contact.put("search","someNewValue");
contact.saveInBackground();
}
Toast.makeText(MainActivity.this, "done", Toast.LENGTH_SHORT).show();
} else {
}
}
});
Actually only 200-300 updated even i run on 1000 items.
is there any limit of fast saveInBackground()?
should i use saveEvantually()?
You should store all object in a List and then call saveAllInBackground. Try like this :
searchQuery.findInBackground(new FindCallback<ParseObject>() {
#Override
public void done(List<ParseObject> results, ParseException e) {
if (e == null) {
ArrayList<ParseObject> phoneObjectList=new ArrayList<ParseObject>();
for(ParseObject contact:results){
contact.put("search","someNewValue");
phoneObjectList.add(contact);
}
ParseObject.saveAllInBackground(phoneObjectList, new SaveCallback() {
#Override
public void done(ParseException e) {
// TODO Auto-generated method stub
if(e==null){
Log.d(TAG, "saved successfully");
Toast.makeText(MainActivity.this, "done", Toast.LENGTH_SHORT).show();
}else{
Log.d(TAG, "Error in saving view count :"+e.getMessage());
}
}
});
} else {
}
}
});
I got an email from parse:
Your app ... recently exceeded 75% of your plan's request
limit of 30 requests/second. Additional requests to Parse exceeding
the rate of 30 requests/second will be dropped, returning an error
with error code 155.
saving data might exceed the exceeded 30 requests/second.
so, saving such of big amount of data should take in consideration...
this is how it looks:
Been there, done that. saveAllInBackground() is crappy. I had to use loop for each object with plain saveInBackground() without callback. And yes - 200,300 save objects from 1000 is normal (for that service). It's not designed to work with batch saves I suppose. And yes - it's easy to exceed limit with saving that much.
I am getting the following exception reported in my Google Analytics for Android app.
ParseRequestException (#ParseRequest:newPermanentException:352) {main}
This is the top exception with more than 4000 hits. I am worried that some users are not able to register on parse and unable to receive push notifications. Unfortunately, I don't have any other information being reported and I am unable to replicate this on any Android devices that I have.
Here is the code, where I am initializing Parse:
Parse.initialize(this, "XXX", "YYY");
ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback() {
#Override
public void done(ParseException e) {
if (e != null) {
Utils.sendException(appContext, e);
}
}
});
PushService.setDefaultPushCallback(this, ChatActivity.class);
ParsePush.subscribeInBackground(getResources().getString(R.string.parse_default_channel), new SaveCallback() {
#Override
public void done(ParseException e) {
if (e != null) {
Toast.makeText(appContext, "Problem subscribing to the chat service. You will not be able to receive notifications!", Toast.LENGTH_LONG).show();
Utils.sendException(appContext, e);
}
}
});
When I searched for this Exception on Google, I found only 3 results and they don't have any info. I want to know:
1. If I am doing something wrong?
2. How this may be hurting my app's users?
3. How to solve this?
Thanks in advance!
I'm using Parse Android SDK v 1.9.2. Notifications are not received for the first time. But if I reinstall the App, then notifications are received.
My ApplicaitonClass
#Override
public void onCreate() {
super.onCreate();
......
Parse.initialize(this, "xxx", "xxx");
.....
}
I'm registering few additional attributes post login and doing saveInBackground ..... onCreate method
The activity is getting called and i'm seeing the logs before saveinbackground and no error on savecallback too.
.saveEventually(new SaveCallback() {
#Override
public void done(ParseException e) {
System.out.println("Done");
if (e == null) {
System.out.println("Parse --- Succesfull Registration.....");
} else {
System.out.println("Parse --- " + e);
}
}
});
But still it doesnt work on the first time, even after closing the app and starting again. However, it works if i reinstall the app.
Kindly let me know what am i doing wrongly.
After trying various examples and debugging, I finally found what i was doing wrongly. I was calling remove key from the parse defaultInstallation in order to avoid the duplicates or array.
So i need to check whether the key exists or not.
if(ParseInstallation.getCurrentInstallation().get("secretId") != null && ParseInstallation.getCurrentInstallation().get("secretId").toString().length() > 0) {
ParseInstallation.getCurrentInstallation().remove("secretId");
}
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.