I tried integrating login with facebook in android with calling registerCallBack from Facebook LoginButton and it worked perfectly. But I wanted to customize my facebook login button with an ImageButton, so I tried performClick() when clicking on my customized ImageButton as below
callbackManager = CallbackManager.Factory.create();
LoginButton btnSignInFacebook = findViewById(R.id.btn_social_sync_facebook);
List<String> permissionNeeds = Arrays.asList("user_photos", "email",
"user_birthday", "public_profile", "AccessToken");
btnSignInFacebook.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
startActivity(new Intent(SocialAccountsSyncActivity.this, AccountInformationSignUpActivity.class));
}
});
Bundle parameters = new Bundle();
parameters.putString("fields",
"id,name,email,gender, birthday");
request.setParameters(parameters);
request.executeAsync();
}
@Override
public void onCancel() {
}
@Override
public void onError(FacebookException error) {
}
});
}
@Override
public void onClick(View view) {
switch (view.getId()) {
//my customized imagebutton
case R.id.ib_social_sync_facebook:
btnSignInFacebook.performClick();
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}
This kept giving me this error:
Unsupported get request. Object with ID '668803530142270' does not exist, cannot be loaded due to missing permissions, or does not support this operation.
Anyone knows the reason please help me with it. Thanks