Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Ayshwarya Jagadeesan](https://secure.gravatar.com/avatar/849b604a8b45b82956b58a732bac6553?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ayshwarya Jagadeesan
36 PointsI want to send push notification to single user but the getobjectId() is not working if I do username.getobjectId().
I want to send push notification to a single user.I have the user name of the user to whom my notification must be sent. If I try username.getobjectId(), android studio throws me an error. Also If I try to have the key as Username instead of user ID. Parse says push has been sent. But Push is not happening in real. What should I do?Please kindly provide me a suggestion.
9 Answers
![Ayshwarya Jagadeesan](https://secure.gravatar.com/avatar/849b604a8b45b82956b58a732bac6553?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ayshwarya Jagadeesan
36 PointsHi Josh,
Thanks for your reply. I have been trying to use the user to user push notification as given in the video for my Chat app. It does not have marking list of recipients
protected void sendPushNotifications() { ParseQuery<ParseInstallation> query = ParseInstallation.getQuery(); query.whereContainedIn(ParseConstants.KEY_USER_ID, buddy.getObjectId());
// send push notification
ParsePush push = new ParsePush();
push.setQuery(query);
push.setMessage(getString(R.string.push_message,
ParseUser.getCurrentUser().getUsername()));
push.sendInBackground();
}
Here the getObjectId throws me an error.Even If I change the line query.whereContainedIn to query.whereEqualsTo. 'buddy' here is the username of the element. Also I understand it is not possble to get Object ID with username. Is there any other method to solve this problem. Also at the installation after sign up and login...the installation is not working. Please kindly let me know a solution.
![Josh Gold](https://secure.gravatar.com/avatar/cd21c645d8002937028946879bf6ea49?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Josh Gold
12,207 PointsBecause you did not post the exact error message, I am going to take a guess at the answer. In the future please post the error message from the LogCat window if you are using Android Studio (or equivalent in Eclipse). With the error message people will be able provide an answer that has a better chance of solving the problem.
Anyhow please try replacing the first two lines of the sendPushNotifications method with the following:
ParseQuery<ParseInstallation> query = ParseInstallation.getQuery();
query.whereContainedIn(ParseConstants.KEY_USER_ID, getRecipientIds());
![Ayshwarya Jagadeesan](https://secure.gravatar.com/avatar/849b604a8b45b82956b58a732bac6553?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ayshwarya Jagadeesan
36 PointsHey I do not have a pool of recipient IDs. I have only the username of the recipient in the form of buddy.
So is there a method to replace getRecipientIds() with buddy.getObjectId?
![Josh Gold](https://secure.gravatar.com/avatar/cd21c645d8002937028946879bf6ea49?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Josh Gold
12,207 PointsDid you try these options? query.whereContainedIn(ParseConstants.KEY_USER_ID, buddy);
query.whereContainedIn(ParseConstants.KEY_USER_ID, "buddy");
![Ayshwarya Jagadeesan](https://secure.gravatar.com/avatar/849b604a8b45b82956b58a732bac6553?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ayshwarya Jagadeesan
36 PointsI did that. In fact, here we actually use User ID to search for a particular user using his user id /object id and then send push notification to him.But I changed that concept, I search for a particular user using his/her username.That way I can use the buddy easily. But even that is not working. Have you implemented this before? The Parse installation after sign up and login takes lot of time to be reflected in parse. How will the user who just logged in get the notification?
![Josh Gold](https://secure.gravatar.com/avatar/cd21c645d8002937028946879bf6ea49?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Josh Gold
12,207 PointsYes I implemented this, but using getRecipientIds() method
![Ayshwarya Jagadeesan](https://secure.gravatar.com/avatar/849b604a8b45b82956b58a732bac6553?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ayshwarya Jagadeesan
36 PointsOk. Then installation after sign up and login worked fine for you?What does getRecipientsId() really do? It just gets the objectId of the checked user/selected user?Did you meet with any delay regarding Parse installation?Please kindly let me know. How does parse search in the installation class?I need more information regarding this . Have you tried for a single recipient?
![Ayshwarya Jagadeesan](https://secure.gravatar.com/avatar/849b604a8b45b82956b58a732bac6553?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ayshwarya Jagadeesan
36 PointsHey If you have implemented this idea.. can you pass on the project file. I want to see the source code. Whatever explained here , it is not working for me. Even for a ribbit application.I want to see the code in action.
![Josh Gold](https://secure.gravatar.com/avatar/cd21c645d8002937028946879bf6ea49?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Josh Gold
12,207 PointsHello Ayshwarya, Here is my source code for Ribbit: https://github.com/jogold9/Ribbit
![Ayshwarya Jagadeesan](https://secure.gravatar.com/avatar/849b604a8b45b82956b58a732bac6553?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ayshwarya Jagadeesan
36 PointsThank you! Will check that out and ask you questions If I have any.
![Ayshwarya Jagadeesan](https://secure.gravatar.com/avatar/849b604a8b45b82956b58a732bac6553?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Ayshwarya Jagadeesan
36 PointsHey Josh, There is no send button in the application. There is edit friends... I select a picture and select a friend...but I am not able to send it. Do you have a working sample? or am I doing it wrongly? I want to see user to user push notification in action.
![Josh Gold](https://secure.gravatar.com/avatar/cd21c645d8002937028946879bf6ea49?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Josh Gold
12,207 PointsI just did what was in the instructions. So whatever functionality there is in the video lessons should be what my code has.
Josh Gold
12,207 PointsJosh Gold
12,207 PointsPost the exact error and the relevant code.