Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Implementing Designs for Android Adding Push Notifications from Parse.com Preparing User-to-User Push Notifications

how to fix getRecepiantsId()

what if my app contains followers and followings and commenting on other people who's not following me and I'm not following them, like instagram for example.

how would I fix the getRecipiatIds() method ..

Vrezh Gulyan
Vrezh Gulyan
11,161 Points

Hey Rawan,

Your question is how would you go about sending push notifications to users who aren't part of your friends list?

Hey Vrezh Gulyan , yes exactly .. and I have one more question. why do we have to use the installation to push notifications ? can't we use the userId from User class directly ?

1 Answer

Vrezh Gulyan
Vrezh Gulyan
11,161 Points

Well for the first part:

Lets say you have a like button and a post button for comments. In the onClick listeners for each of these buttons you could record the userId for these people even if they aren't of your friends. So each time a person likes or comments you get notified and their userId is recorded. Furthermore if lets say you want to notify them if you comment back to their comment you'd be able to. You can do it like Facebook does it where when you comment on someones picture you get notified whenever anyone else does too. Off the top of my head I can see this simply being done by keeping an array of userId's of anyone who commented on a certain picture and as soon as someone comments send a notification to all these people.

As far as why use installation for push notification it has to do more technical parts of each individual phone that you send notifications to. When you install on each individual phone it stores all the needed data to send notifications, technical phone information, what categories of push messages to send etc. Then from the parse.com website in the push category you can target specific phones without knowing userId's. Like when installing you can set whether each user wants to get comment notifications or not ( they can also change this themselves in settings) that way when you send push notifications you can send it to everyone and let the installation part that we did earlier take care of who gets what.