Issue
I can successfully use firebase realtime with xamarin using Plugin.CloudFirestone.
I use the listener this way:
CrossCloudFirestore.Current.Instance.Collection("yourcollection")
.Document("yourdocument")
.AddSnapshotListener((snapshot, error) =>
{
...
});
But when the user logout I need to stop listening. Does anyone know how to do it? I've read the official material but I couldn't get any information about it. thanks!
Solution
As the documentation on detaching a listener shows, you can call Stop() on the object that is returned when you attach the listener:
DocumentReference query = db.Collection("yourcollection")..Document("yourdocument")
ListenerRegistration listener = query.Listen(snapshot => {
foreach (DocumentSnapshot documentSnapshot in snapshot.Documents) {
Debug.Log(documentSnapshot.Id);
}
});
And then later:
listener.Stop();
This call will stop the listener from receiving further updates.
Answered By - Frank van Puffelen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.