We have developed and tested a Flutter app. Everything works as expected. We deployed an app to stores and gain some users.
After a few months, we got complaints from our users that they lost all their data when they opened the app.
I believe that the data is not lost, only their anonymous account changed to the new anonymous account.
What users, with lost data, have in common:
- iOS devices (not sure if relevant),
- didn't use the app for at least a few days.
Our user authentication flow:
- App starts,
- All services are initialized in
main()method, AuthServiceinitializefinal _auth = FirebaseAuth.instance;and callsloginUser(),loginUser()method executes:
void loginUser() async {
FirebaseUser user = await _auth.currentUser();
if (user == null) {
AuthResult result = await _auth.signInAnonymously();
user = result.user;
}
IdTokenResult userToken = await user.getIdToken();
print('USER');
print(' UID: ${user.uid}');
print(' Token: ${userToken.token}');
print(' Expires: ${userToken.expirationTime}');
}
We are using versions:
flutter: v1.12.13+hotfix.7firebase_core: ^0.4.0+8firebase_auth: ^0.14.0+5
We didn't experience any problems with registered users.
Questions:
- In what cases would
this._auth.currentUser()return null? - Is there an expiry date for the anonymous account?
- Is there a way to reproduce this issue?
- Did someone experience the same issue?
- What are we doing wrong?
- How can this be avoided for anonymous users?