I need clarification on implementing a simple remember me.
I have created a remember me checkbox that a user would check and this would pass a true value to the stayLoggedIn boolean now in order to skip the login and start the HomeActivity I would have to check both the userToken. I’m confused on how to do this. The SDK was a bit confusing to me on how to do this this what I somewhat understood but I know it’s incorrect. I would greatly appreciate any help.
AsyncCallback<Boolean> isValidLoginCallback = new AsyncCallback<Boolean>()
{
@Override
public void handleResponse(Boolean response) {
if(response){
String userToken = UserTokenStorageFactory.instance().getStorage().get();
if( userToken != null && !userToken.equals( “” ) )
{startActivity( new Intent( getBaseContext(), HomeActivity.class ) );}
}}
@Override
public void handleFault(BackendlessFault fault) {
}
};
Backendless.UserService.isValidLogin( isValidLoginCallback );
public void Backendless.UserService.login( String login,
String password,
AsyncCallback<BackendlessUser> callback,
boolean stayLoggedIn, );
use the stayLoggedIn parameter- true to stay logged in.
Could you clarify which part is confusing? Do you need to know how to check if there is a persisted user token? Do you need to know how to check if it is valid? I believe both of these scenarios are in the docs.
I need to check if there is a persisted user token could you please point me in the right direction.
when I implement the above version of the login method I get errors.
Backendless.UserService.login(etUser.getText().toString(), etPass.getText().toString(), new DefaultCallBack<BackendlessUser>(MainActivity.this),rememberbl){public void handleResponse(BackendlessUser backendlessUser) {//implementation}public void handleFault( BackendlessFault fault )
{//implementation}
remembl being a boolean