Document Comes Back After Deleting From Firestore Database.

Asgar Ali 86 Reputation points
2022-10-21T10:18:54.293+00:00

In my application I am deleting a document from Firestore database.After deleting The user is redirected to the Mainpage.When the user login with his google account.The document comes back.while checking the Firestore database the document is deleted from the Firestore Database.The code for deeting the document is as below

 public async Task<bool> Delete(User user)  
        {  
            try  
            {  
                var collection = Firebase.Firestore.FirebaseFirestore.Instance.Collection("User");  
                collection.Document(user.Id).Delete();  
                FirebaseFirestore.Instance.Terminate();  
                FirebaseFirestore.Instance.ClearPersistence();  
                return true;  
            }  
            catch (System.Exception) { return false;}  
  
        }  

this happens not all the time.sometimes the document is deleted.sometimes the document comes back

Developer technologies | .NET | Xamarin
Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. Rob Caplan - MSFT 6,037 Reputation points Microsoft Employee Moderator
    2022-11-03T22:55:17.547+00:00

    My question is How can i clear the Cached Data after deleting the users data.

    Since you're asking about Firebase behaviour the best place to find info is in the Firebase docs and repos.
    A quick search turned up the the following:

    https://github.com/firebase/firebase-android-sdk
    Issue: Clear Local Cache while persistenceEnabled is turned on #466
    Pull: Make clearPersistence() publicly available #455

    And in the Firebase docs:
    https://firebase.google.com/docs/reference/android/com/google/firebase/firestore/FirebaseFirestore#clearPersistence()

    If you're running into bugs with Firebase getting out of sync you can report them to the Firebase team at https://firebase.google.com/support

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.