VivekScorp
Member
- Joined
- May 12, 2022
- Messages
- 11
- Programming Experience
- 3-5
I have a class in android which has a listener setup to get visitorlist updates.
and when the firestore db is updated the following method runs and gets the updates
Now I want to add another listener to get residentdetails like this
How do I tell this listener to run a different function like
when the firestore db is updated?
C#:
var visitorDetailsCollection = FirebaseFirestore.Instance.Collection("visitorDetails");
var visitorDetailsquery = visitorDetailsCollection.WhereEqualTo("UserID", Firebase.Auth.FirebaseAuth.Instance.CurrentUser.Uid);
visitorlistner = visitorDetailsquery.AddSnapshotListener(this);
and when the firestore db is updated the following method runs and gets the updates
C#:
public void OnEvent(Java.Lang.Object obj, FirebaseFirestoreException error)
{
try
{
var docs = (QuerySnapshot)obj;
visitorDetails.Clear();
foreach (var doc in docs.Documents)
{
var visitordetails = new VisitorDetails
{
Name = doc.Get("VisitorName").ToString(),
ContactNumber = doc.Get("VisitorContact").ToString(),
VehicleNumber = doc.Get("VisitorVehicleNo").ToString(),
IsApproved = doc.Get("VisitorIsApproved").ToString(),
IsActive = doc.Get("VisitorIsActive").ToString(),
Purpose = doc.Get("PurposeOfVisit").ToString(),
Email = doc.Get("VisitorEmail").ToString(),
FromDate = toDatetime(doc.GetDate("FromDate") as Date),
ToDate = toDatetime(doc.GetDate("ToDate") as Date),
docID = doc.Id
};
visitorDetails.Add(visitordetails);
}
Now I want to add another listener to get residentdetails like this
C#:
residentlistner = residentDetailsquery.AddSnapshotListener(this);
How do I tell this listener to run a different function like
C#:
public void OnEvent2(Java.Lang.Object obj, FirebaseFirestoreException error)
{}