Login with facebook crash the app if using FaceBook Lite

13,551

You know FB's motto - move fast and break things. SDK integration with native apps is one of the things that sometimes breaks.

You can force Facebook SDK to use web for login:

LoginManager.getInstance().setLoginBehavior(LoginBehavior.WEB_ONLY)
Share:
13,551

Related videos on Youtube

Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    In my app I'm using facebook SDK to perform a login and register methods.

    It's Okay when I have the general FaceBook application or using normal web-browser on my device.

    But when I have FaceBook Lite on my device and I don't have the general FaceBook application, when I try to login/sign up using the facebook-sdk the app just close without any log/messages, So I can't know why this issue happened.

    How can I fix that issue? - Can I skip FaceBook Lite app and use browser instead?

    Update:

    Here is a video if I have normal facebook app, no problems.

    Here is a video if I have the face book app lite on my device, which make it crash.

    My code snippet:

    LoginManager.getInstance()
                        .logInWithReadPermissions(getActivity(), Arrays.asList("public_profile"));
    
                LoginManager.getInstance()
                        .registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
                            @Override
                            public void onSuccess(final LoginResult loginResult) {
                                Log.i("MainActivity", "@@@onSuccess");
                                GraphRequest request = GraphRequest
                                        .newMeRequest(loginResult.getAccessToken(),
                                                (object, response) -> {
                                                    Log.i("MainActivity",
                                                            "@@@response: " + response.toString());
    
                                                    try {
    
                                                        ///
                                                    } catch (JSONException e) {
                                                        ////
    
                                                    }
                                                });
    
                            }
    
                            @Override
                            public void onCancel() {
                                Log.i("MainActivity", "@@@onCancel");
                            }
    
                            @Override
                            public void onError(FacebookException error) {
                                Log.i("MainActivity", "@@@onError: " + error.getMessage());
                            }
    
                        });
    
  • Admin
    Admin almost 6 years
    Thank's it will be a prefect answer If I can use general facebook app if exist on the device, because there is a lot of users using it.
  • Nainal
    Nainal almost 6 years
    @Ibrahim Don't change the LoginBehavior becasue the deafult LoginBehavior is NATIVE_WITH_FALLBACK, which will open native FB app if installed and if app is not installed it will open web dialog.
  • TpoM6oH
    TpoM6oH almost 6 years
    Yes, but it does not fall back in some cases resulting in users experiencing crashes and being not able to log in.