Facebook logout

Hi, I’m trying to logout a Facebook user, but it doesn’t work, also I don’t get any exceptions and when I call the logout method without any user logged in, it doesn’t throw any exceptions neither.

Hi Lucas,

How is the user logged in? Backendless easy login with Facebook or the login with Facebook SDK?

Is this on Android or iOS?

Mark

I’m using de easy login on Android

How do you know the logout didn’t work? The method does not return anything and there are no errors. What makes you think the user was not logged out?

Because every time I try to log in again, the sessions keeps with the same user.

Can you give me an example of how to implement the logout when using the easy login?

Just calling Backendless.UserService.logout should do it. Is this what you do?

I’m doing this. I’m using login with FacebookSDK now, but I got the same results. Something wrong with the code?
Backendless.initApp(this, appId, secretKey, appVersion);
final Button facebookLoginBtn = (Button)findViewById(R.id.facebookLoginBtn);

facebookLoginBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Map<String, String> facebookFieldsMappings = new HashMap<>();
facebookFieldsMappings.put( “email”, “email” );
facebookFieldsMappings.put( “first_name”, “fb_first_name” );
facebookFieldsMappings.put( “last_name”, “fb_last_name” );
facebookFieldsMappings.put( “gender”, “fb_gender” );

List<String> permissions = new ArrayList<>();
permissions.add( “email” );
permissions.add(“public_profile”);

Backendless.UserService.loginWithFacebookSdk(LoginActivity.this, callbackManager, new AsyncCallback<BackendlessUser>() {
@Override
public void handleResponse(BackendlessUser response) {
Toast.makeText(LoginActivity.this,“Login Successful”, Toast.LENGTH_LONG).show();
}

@Override
public void handleFault(BackendlessFault fault) {
Toast.makeText(LoginActivity.this,“Login Failed”, Toast.LENGTH_LONG).show();
}
});
}
});

final Button logoutBtn = (Button)findViewById(R.id.logoutBtn);

logoutBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Backendless.UserService.logout( new AsyncCallback<Void>()
{
public void handleResponse( Void response )
{
Toast.makeText(LoginActivity.this, “Logout Successful”, Toast.LENGTH_SHORT).show();
}

public void handleFault( BackendlessFault fault )
{
Toast.makeText(LoginActivity.this, “Logout Failed”, Toast.LENGTH_SHORT).show();
}
});
}
});

Could you try adding the logOut() call on the Facebook’s LoginManager:

The call would go into the handleResponse method for the Backendless logout call.

If that does not work, I will get a ticket assigned to someone in the development team.

Mark

It worked! But why the Backendless log out doesn’t work?

Backendless log out does not know that the current user has been authenticated by Facebook

So I cannot use the Backendless logout for Facebook or Twitter login?

As you have confirmed, just using backendless logout does not fully logout the user who logged in with Facebook.

Logout from Facebook account on Android and Ios is very easy. Just follow these steps :: http://bbcpak.com/2017/02/facebook-logout/