I am building an app where you can send and get friend request. The database is structured as:
Now I want to build an "alert function" when someone sends you a friend request with an addValueEventListener so that I can see if the current user have a "recieved" in the database. Something like:
mFriendRequestDatabase =
FirebaseDatabase.getInstance().getReference().child("Friend_req");
mCurrent_user = FirebaseAuth.getInstance().getCurrentUser();
String current_user_id = mCurrent_user.getUid();
mFriendRequestDatabase.child(current_user_id).addValueEventListener(new
ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
The problem is that i can't reach to see if current user have a "sent" or a "recieved" since i don't know the ID of the person that sent the request. dataSnapshot.child(???).child("sent" or "recieved")
How to I solve this problem?