Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear firebase cache?

I'm facing an issue where when I sign out a user (using FirebaseAuth.signOut() method) and sign in with another user, information of the previous user are loaded instead of the new one.

I believe this is caused by this information still being accessible in firebase's cache.

Is there a way to force firebase to clear its local cache?

Cheers!

like image 870
Théo Champion Avatar asked Nov 17 '19 16:11

Théo Champion


2 Answers

For Android, there is FirebaseFirestore.clearPersistence().

For JavaScript/web, there is Firebase.clearPersistence().

For iOS, there is Firebase.clearPersistence().

Flutter does not seem to have this API yet.

Bear in mind that the clearPersistence API is not meant for the specific case you're talking about. If you read the API docs carefully, you can see they're meant for testing.

You might want to do a little more debugging to figure out what exactly it is that's not working the way you expect. Since you're not showing any code, it's hard to tell if you might be doing something wrong.

like image 75
Doug Stevenson Avatar answered Oct 20 '22 19:10

Doug Stevenson


You can use the async call FirebaseFirestore.instance.clearPersistence(); for flutter projects. Check this answer.

like image 35
Dpedrinha Avatar answered Oct 20 '22 19:10

Dpedrinha