Facebook Login Callback Issue

0 votes

Hi, Im attaching a snippet from my code:


protected void onCreate(Bundle savedInstanceState) { FacebookSdk.sdkInitialize(getApplicationContext()); callbackManager = CallbackManager.Factory.create();
fbloginButton= (LoginButton) findViewById(R.id.login_button);
fbloginButton.setReadPermissions("public_profile", "email","user_friends");
temp = (TextView) findViewById(R.id.temp);
}

 

private void FBLogin() {
    System.out.print("Initializing facebook login");
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            temp.setText("Welcome " + loginResult.getAccessToken().toString());
            //System.out.print(loginResult.getAccessToken());
            final AccessToken accessToken = loginResult.getAccessToken();
            GraphRequest graphRequest = GraphRequest.newMeRequest(accessToken, new GraphRequest.GraphJSONObjectCallback() {
                @Override
                public void onCompleted(JSONObject object, GraphResponse response) {
                    try{
                        usermail = object.getString("email");
                        uname = object.getString("name");
                    }
                    catch (Exception e){
                        e.printStackTrace();
                    }
                    SocialService socialService = App42API.buildSocialService();
                    socialService.linkUserFacebookAccount(usermail, accessToken.toString(), new App42CallBack() {
                        @Override
                        public void onSuccess(Object o) {
                            
                        }

                        @Override
                        public void onException(Exception e) {

                        }
                    });
                }
            });
        }

 


Okay so what is happeneing is that, the login is working i guess! Becasue when i click  on login, the Facebook UI opens up and asks for permission to login. I can say this because, the login button changes to a logout button automatically and when i click on it, it gives a proper popup that i was logged in as <name>.

The issue now is that the method onSucess() in the FacebookCallback is not beijng called since the temp text is not being changed and as a resut the rest of the code including the registerOnApp42 for the facebook is not working,

Itll be great if you can help me fix this. 

asked May 12, 2016 in Android by checker.kshitij (10 points)
I have also implemented the onActivityResult method

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        callbackManager.onActivityResult(requestCode, resultCode, data);
    }

1 Answer

0 votes

Hi Checker,

There can be issue in Face Book SDK integration as Facebook have changed many features recently. You can go through with FaceBook Documentation that will help you in integration process.

Once You will get a success callback from Face Book, you can easily link account with App42.

Let me know If you have any query in integration.

 

Thanks

Vishnu Garg

answered May 13, 2016 by Vishnu Garg (674 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...