User login (staying logged in on app restarts)


I noticed 3 things in the documentation about login

Backendless.UserService.login( username, password );

and I am confused to the sequence of events (or what to do for my case). It seems the above 3 methods essentially do the same thing (or perhaps they have different use cases that I dont understand).

Basically assuming the user is registered. Now lets say he opens the app to login. I would like to validate his login credential. I assume this is where the “login” method used for.

Now let’s say that he killed the app or restarted the phone. I would like the user to continue using the app without the need to login again. would calling isValidLogin or getStorage().get() be valid here?
What is needed here to achieve the above? Please keep in mind that I am open to store things locally if needed
Thank you

Hi SnakeEyes!

When logging the user in you may set stayLoggedIn parameter to ‘true’. It will store the user’s login information so the login form can be skipped next time the user launches the app. Sync and async methods are described here.

Best regards

You use login to “login” a user into the app.

You use “isValidLogin” to check if the user token from a previous persisted login is still valid.

You use “UserIdStorageFactory.instance().getStorage().get()” to get the objectId of the logged in user.

I believe the documentation says the same thing.