Все пользовательские уведомления удаляются, когда из Firebase нужно удалить только одно

Я написал два метода в своем PostAdapter: один для добавления уведомлений в Firebase и отправки их пользователю, а другой для удаления из Firebase. Проблема, с которой я столкнулся сейчас, заключается в том, что при добавлении уведомлений в Firebase я вижу, что они есть, но затем, если я хочу удалить их, например, если кому-то нравится ваш пост или он оставляет вам комментарий, другой пользователь получает уведомление, но если Я удаляю комментарий или удаляю сообщение, так как уведомления должны быть удалены, но удаляются все уведомления этого пользователя, а не только те, которые я хочу удалить. Как я могу изменить код, чтобы вместо всех удалялось только уведомление Firebase, которое я хочу удалить?

PostAdapter

holder.like.setOnClickListener(v -> {
            if (holder.like.getTag().equals("like")) {
                FirebaseDatabase.getInstance().getReference().child("Likes").child(post.getPostid()).child(mFirebaseUser.getUid()).setValue(true);
                addNotification(post.getPublisher(), post.getPostid());
            } else {
                FirebaseDatabase.getInstance().getReference().child("Likes").child(post.getPostid()).child(mFirebaseUser.getUid()).removeValue();
                deleteNotification(post.getPublisher());
            }
        });

 private void addNotification(final String userid, final String postid) {
        DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Notifications").child(userid);

        String notificationId = reference.push().getKey();

        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("userid", mFirebaseUser.getUid());
        hashMap.put("comment", "liked your event");
        hashMap.put("postid", postid);
        hashMap.put("notificationId", notificationId);
        hashMap.put("ispost", true);

        if (notificationId != null)
            reference.child(notificationId).setValue(hashMap);
    }

    private void deleteNotification(String userid) {
        DatabaseReference reference = FirebaseDatabase.getInstance().getReference("Notifications").child(userid);
        reference.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
                    Notification notification = snapshot.getValue(Notification.class);
                    if (notification != null) {
                        reference.child(notification.getNotificationId()).removeValue();
                    }
                }
            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        });
    }

Ответы (0 шт):