Home > Software design >  How to store information about login in mobile application (offline or online)?
How to store information about login in mobile application (offline or online)?

Time:03-19

I made a simple application that allows you to take pictures offline and tag them. As soon as there is an internet connection, these data are sent to the server. I use a great backend solution - Appwrite. It works very well.

The last thing I wanted to do was user registration and login. The AppWrite SDK provides ready-made methods for creating user sessions, authentication. However, I have a problem how it should work if my application also works offline. E.g.

  1. I have an internet connection - I log in to the application - a session is being created.
  2. The next time you turn on the application, the login screen should not appear anymore. How is the application to know that a session is active and not to display the login screen if I do not have internet access?
  3. The same if I log out of the app when I do not have internet, the previous session will not be deleted.

I would be grateful for any advice on how to achieve this. To sum up - Should user login information be written somewhere local?

CodePudding user response:

The simplest way is to use shared_preferences (offline) https://pub.dev/packages/shared_preferences and firestore (online) https://firebase.flutter.dev/docs/firestore/usage/

CodePudding user response:

Use Sharedpreference for local storage : here

  • Related