Search code examples
androidfacebookpublish

Unable to get Facebook Publish Permission - Android


I am trying to get the publish_actions permission from the user for my app. The user has already logged in through facebook and in that instance I asked for some read permissions that the app needs. Getting the read permissions worked fine but there seems to be some problem with publish_actions. My code is:

private void asktopublish() {
    LoginManager.getInstance().logInWithPublishPermissions(this, Arrays.asList("publish_actions"));
    CallbackManager callbackManager = CallbackManager.Factory.create();

    LoginManager.getInstance().registerCallback(callbackManager,
            new FacebookCallback<LoginResult>() {
                @Override
                public void onSuccess(LoginResult loginResult) {
                    Toast.makeText(getApplicationContext(), "Done", Toast.LENGTH_LONG);
                }

                @Override
                public void onCancel() {
                }

                @Override
                public void onError(FacebookException error) {

                }
            });
}

When the user clicks the button on my to grant the permission, the Facebook activity opens but closes almost instantly and seems to be empty as well.

I've tried looking for other solutions online but they all use the older fb sdk.


Solution

  • As @MBat suggested, I added the user as a tester and it works