I am developing an app and currently only login with the same account. I logged in with a different account yesterday ... and found that the data on some pages was still there from the previous login, which is not ideal!!
The logout process does this:
// Clear the credentials store
CredentialsStorage.ClearAll();
SessionManager.Instance.EndTrackSession();
await Shell.Current.GoToAsync("//LoginPage");
Which seems to work, the credentials are updated / changed when logging in again but the data on a previously visited page (e.g. statement) still exists from the previous login and gets added to for the new login.
So, I assume the instance of the statement page is still in existance and therefore its data. How do I clear all of that? Or do I need to change how / when I load data?
The statement page, for example, has a CollectionView bound (ItemSource) to a ViewModel. The ViewModel constructor creates a new ObservableRangeCollection(). In OnAppearing(), I call LoadItemsCommand in the ViewModel to get the first lot of data.
It's good that the data is still there, while a user is logged in and switching between screens (I think?), but obviously I need to clear it when the user logs out / a new user logs in.
BTW, it's perfectly possible that I'm not fully grasping how Xamarin Forms and the Page lifecycle works, so any help or pointers would be most welcome!