Synced Realm is not cleared on logout

docs

#1

Hello, I have yet another question on Realm logout flow.

The documentation for the SyncUser.logut() method states that:

Log a user out, destroying their server state, unregistering them from the SDK, and removing any synced Realms associated with them, from on-disk storage on next app launch (or directly if all instances are closed).

Any Realms owned by the user will be deleted, when the application restart.

But in my tests, when I call the SyncUser.current().logOut(), and then login with different user - the old users’ Realm file is still present on android (alongside new Realm) and I can grab this old Realm db file form device and open in Realm Studio. Studio still shows all the data in this file.

Is this an intended behaviour? How can I ensure that the old Realm is deleted?


#2

I am also having problems with logout. I reported this issue back in June, but it hasn’t been fixed yet. Even with the workaround I listed in the GitHub issue, switching users is not working reliably. I get a lot of ClientResetErrors when logging one user out and switching to another.

@realm Is there a recommended way to switch users?


#3

Also I think it is a bit problematic that the realm files are cleared on application restart. There is no way to reliably restart an app in either Android or iOS (were it will get you rejected by apple). I am not sure how to do proper user switching with realm :confused:

I did try now to see if I could force the app to finish when signing out as an alternative, but after reading this post https://stackoverflow.com/questions/2033914/is-quitting-an-application-frowned-upon, I don’t think it is a good idea… at all.