I´ve been trying to implement Facebook login in my Android App without success. Due to design reasons, I want to implement Facebook login without using the LoginButton that the SDK provides. I have used the LoginManager and CallbackManager clases for this purpose. My code works fine when the user is not logged in the Facebook App, but if the user has an open session in the Facebook App, I get an error that says:
Error App Not Setup: The developers of this app have not set up this app properly for Facebook Login.
I'm sure the App is correctly configured in Facebook and that I have everything in my manifest and gradle files according to the Facebook developers tutorial, so I don´t know what is wrong. I would really appreciate any help with this topic, I need to get this working to continue with the App development. Thanks! Here is my code related to the Facebook login:
In onCreate(...) method
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
btnFacebookLogin.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
facebookLogin();
}
});
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>()
{
@Override
public void onSuccess(LoginResult loginResult)
{
Log.i("LoginActivity","onSuccess Facebook Login");
Toast.makeText(getApplicationContext(),"Login successful",Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel()
{
}
@Override
public void onError(FacebookException e)
{
Log.e("LoginActivity","ERROR: "+e.getMessage());
}
});
And here my facebookLogin() method:
public void facebookLogin()
{
LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("public_profile"));
}
And the onActivityResult(...)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
Again thanks for any help!!
Aucun commentaire:
Enregistrer un commentaire