I have the following code and getting an error :
Invalid collection reference. Collection references must have an odd number of segments
And the code :
private void setAdapter() {
FirebaseFirestore db = FirebaseFirestore.getInstance();
db.collection("app/users/" + uid + "/notifications").get().addOnCompleteListener(task -> {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
Log.d("FragmentNotifications", document.getId() + " => " + document.getData());
}
} else {
Log.w("FragmentNotifications", "Error getting notifications.", task.getException());
}
});
}
Then you need change this:
db.collection("app/users/" + uid + "/notifications")...
for this:
db.collection("app").document("users").collection(uid).document("notifications")
You welcome ;)