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

challenge 2

Now, save currentUserId in the ParseInstallation variable using the put() method. Use the key "userId".

please help um stuck on this one

LoginActivity.java
import android.app.Activity;
import android.os.Bundle;
import com.parse.ParseInstallation;
import com.parse.ParseUser;

public class LoginActivity extends Activity {

    /*
     * Some code has been omitted for brevity!
     * This method gets called upon a successful login.
     */

    public void updateParseInstallation() {
        String currentUserId = ParseUser.getCurrentUser().getObjectId();

      ParseInstallation installation = ParseInstallation.getCurrentInstallation();
     installation.put("userId", ParseUser.getCurrentUserId());
          }
}
InviteActivity.java
import android.app.Activity;
import android.os.Bundle;
import com.parse.ParseInstallation;
import com.parse.ParseQuery;

public class InviteActivity extends Activity {

    /*
     * Some code has been omitted for brevity!
     * This method gets called when an invitation is sent.
     */

    public void sendPushNotifications(String playerId) {
        ParseQuery<ParseInstallation> pushQuery;
    }
}

3 Answers

Right - got it.

        String currentUserId = ParseUser.getCurrentUser().getObjectId();

        ParseInstallation installation;
        installation = ParseInstallation.getCurrentInstallation();
        installation.put("userId", currentUserId);

Hope that makes sense!

i got it thanks.....

I haven't done this course yet but will in the future, I'm sure.

However, in your line, installation.put("userId", ParseUser.getCurrentUserId()); the second parameter has already been resolved above and stored in currentUserID.

Could your line be amended slightly to look like:

installation.put("userId", currentUserID);