0

I am using this code for fetching fb user info for my android app.

My issue is that this code doesn't returns Date of Birth of all users i.e, If I login through through user A, it returns DOB but if I login through user B it doesn't. Both the users have saved dob in fb and also have privacy settings.

private LoginButton loginButton;
private CallbackManager callbackManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

loginButton = (LoginButton) findViewById(R.id.login_button);

loginButton.setReadPermissions(Arrays.asList(
        "public_profile", "email", "user_birthday", "user_friends"));

callbackManager = CallbackManager.Factory.create();

// Callback registration
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
    @Override
    public void onSuccess(LoginResult loginResult) {
        // App code
        GraphRequest request = GraphRequest.newMeRequest(
                loginResult.getAccessToken(),
                new GraphRequest.GraphJSONObjectCallback() {
                    @Override
                    public void onCompleted(JSONObject object, GraphResponse response) {
                        Log.v("LoginActivity", response.toString());

                        // Application code
                        String email = object.getString("email");
                        String birthday = object.getString("birthday"); // 01/31/1980 format
                    }
                });
        Bundle parameters = new Bundle();
        parameters.putString("fields", "id,name,email,gender,birthday");
        request.setParameters(parameters);
        request.executeAsync();


    }

    @Override
    public void onCancel() {
        // App code
        Log.v("LoginActivity", "cancel");
    }

    @Override
    public void onError(FacebookException exception) {
        // App code
        Log.v("LoginActivity", exception.getCause().toString());
    }
});

}

If anybody knows something please share.

Community
  • 1
  • 1
Atula
  • 2,177
  • 2
  • 12
  • 28

1 Answers1

0

I assume that not both users have a role in the App and user_birthday is not approved. Please take a look at the docs about Login Review: https://developers.facebook.com/docs/facebook-login/review

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • i didn't get you. can you explain that – Atula Nov 02 '16 at 12:23
  • did you check out the link in my answer? you need to get user_birthday approved by facebook first, or it will only work for users with a role in the app. – andyrandy Nov 02 '16 at 12:28
  • i am giving permission of "user_birthday" but it got denied – Atula Nov 02 '16 at 12:49
  • at https://developers.facebook.com, in your app dashboard, you have a category named: APP REVIEW and there you can add items in your review and explain why you need that permission ( you need to record also a movie , even with your phone camera, to show your login/register system). – Vas Hanea Feb 16 '17 at 09:53