I'm following the facebook android sharing tutorial by facebook (https://developers.facebook.com/docs/android/share). The app runs fine and I can login with facebook an click on the demo share button. So this is the procedure of my app:
user_likes, user_friends, user_status, basic_info
publish_actions
is madeThe following code performs this request:
public class MainActivity extends Activity {
private Button shareButton;
private UiLifecycleHelper uiHelper;
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization";
private boolean pendingPublishReauthorization = false;
...
private void publishStory() {
Session session = Session.getActiveSession();
if( session != null) {
List<String> permissions = session.getPermissions();
if(!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS);
//Request the new permission here. The answer is processed in onSessionStateChange() method
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
...
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
//since the session is already open we enter this if branch
if (state.isOpened()) {
shareButton.setVisibility(View.VISIBLE);
//The result of state.equals(SessionState.OPENED_TOKEN_UPDATED) is false which indicates that the session object has not been updated (as far as I understand the fb api)
Log.e(TAG, "state.equals(SessionState.OPENED_TOKEN_UPDATED) = " + state.equals(SessionState.OPENED_TOKEN_UPDATED));
//Output all the current permission the session has (publish_actions is not included here)
List<String> permissions = session.getPermissions();
Iterator<String> it = permissions.iterator();
Log.e(TAG, "Content of list:");
while(it.hasNext())
Log.e(TAG, "permission = " + it.next());
//Since the OPENED_TOKEN_UPDATED has not been updated nothing further happens here
if (pendingPublishReauthorization && state.equals(SessionState.OPENED_TOKEN_UPDATED)) {
pendingPublishReauthorization = false;
publishStory();
}
} else if (state.isClosed()) {
shareButton.setVisibility(View.INVISIBLE);
}
}
So, although this seems to be correct there must be some remaining error. The publish_actions permission is not granted however I do not understand why. Only the existing permissions remain publish_actions
.
Further remark: I've read some questions that say that an additional popup should appear asking the user to grant the permission. However this does not happen in my case. Maybe this is the problem? If so, what do I have to do to get the popup window?
UPDATE: I also additionally tried the following gist from github: https://gist.github.com/vishalpawale/5556996 This sample code fails due to the exact same reason. It does not get any publish_action permission. Seems to be a actual bug in the Facebook SDK?
For publish permission you should send request in app settings and send for review, see https://developers.facebook.com/docs/apps/review/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With