Search code examples
androidfacebookandroid-simple-facebook

publish_actions is not requested in the new SDK


We are using

Permission[] permissions = new Permission[] {
        Permission.PUBLIC_PROFILE,
        Permission.EMAIL,
        Permission.USER_FRIENDS,
        Permission.PUBLISH_ACTION
    };
SimpleFacebookConfiguration configuration = new SimpleFacebookConfiguration.Builder()
        .setAppId(getResources().getString(R.string.app_id))
        .setNamespace("ournamespace")
        .setPermissions(permissions)
        .build();

        SimpleFacebook.setConfiguration(configuration);   

In the login activity:

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

@Override
public void onResume() {
    super.onResume();
    mSimpleFacebook = SimpleFacebook.getInstance(this);     
}
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    ctx = this;

    ImageView fbBtn = (ImageView) findViewById(R.id.authButton);
    fbBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mSimpleFacebook.login(onLoginListener);
        }
    });
}   

However, the access token that is generated doesnt include the publish_actions permission... what is wrong here?

Thanks!


Solution

  • In one of the recent changes of this library, added new option to SimpleFacebookConfiguration. It is called setAskForAllPermissionsAtOnce. If the value is true then it asks for all permissions at once and you will have the PUBLISH permissions in the accessToken if user accept it on login.

    If it is false then it behaves in different way. Only when user makes his first PUBLISH action, only then the dialog with permissions will be shown for the first time. The default value is false since this complies better to Facebook policy. But you can change it. Check all options here: https://github.com/sromku/android-simple-facebook#configuration-options

    You can also use SimpleFacebook.requestNewPermissions() method to ask for permissions again or for new one in the middle of your app flow, when you decide it is good to ask from user.