Facebook使用Backendless获得性别回报为空

时间:2018-06-29 18:33:07

标签: android backendless

我将Backendless用作BaaS。我想使用android SDK v4.5.1用facebook登录到Backendless并获取一些个人信息。生日和名字字段有效,但性别始终为空。我使用纯Facebook SDK 4.34.0尝试了相同的操作,并且按预期工作。

这是我的后端登录(性别为空)

public void facebookLogin() {
        LoginManager.getInstance().logInWithReadPermissions(this, Arrays.asList("email", "user_birthday", "user_photos", "user_gender", "public_profile"));
    }

    private void loginToBackendlessWithFacebook() {
        Map<String, String> facebookFieldMappings = new HashMap<>();
        facebookFieldMappings.put("first_name", UserProperty.USERNAME.getPropertyName());
        facebookFieldMappings.put("birthday", UserProperty.BIRTHDAY.getPropertyName());
        facebookFieldMappings.put("gender", UserProperty.GENDER.getPropertyName());
        Backendless.UserService.loginWithFacebookSdk(fbAccessToken, facebookFieldMappings, new AsyncCallback<BackendlessUser>() {
            @Override
            public void handleResponse(BackendlessUser response) {
                setCurrentUserAndProceed(); // Here gender is null
            }
            @Override
            public void handleFault(BackendlessFault fault) {
                log.error("Could not backendless login to facebook {}", fault.getMessage());
            }
        }, true);
    }

这是普通的Facebook请求(性别正确)

GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(),
            new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(JSONObject object, GraphResponse response) {
                    try {
                        System.out.println();
                    } catch (Exception e) {}}
            });
    Bundle parameters = new Bundle();
parameters.putString("fields", "gender");
request.setParameters(parameters);
request.executeAsync();
}

有什么建议吗?

0 个答案:

没有答案