With the Realtime Database, one could do this :
MyPojo pojo = dataSnapshot.getValue(MyPojo.Class);
as a way to map the object, how does one do this with Firestore
?
CODE :
FirebaseFirestore db = FirebaseFirestore.getInstance();
db.collection("app/users/" + uid).document("notifications").get().addOnCompleteListener(task -> {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document != null) {
NotifPojo notifPojo = document....// here
return;
}
} else {
Log.d("FragNotif", "get failed with ", task.getException());
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…