I'm having trouble while trying to retrieve an additional permission "publish_action".
I assume that user has already logged in via facebook thus basic permissions are granted. Then I have this code (from my fragment):
List<String> permissionsRequested = Arrays.asList("publish_actions");
List<String> permissionsActual = session.getPermissions();
if (!isSubsetOf(permissionsRequested, permissionsActual)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, permissionsRequested);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
Seeing from debug, after user grants permission, control goes to onActivityResult, where, according to facebook docs, I have
super.onActivityResult(requestCode, resultCode, data);
facebookUiHelper.onActivityResult(requestCode, resultCode, data);
uiHelper is also properly (acording to the docs) used in all those onResume&onDestroy methods.
In onCreate I have
super.onCreate(savedInstanceState);
facebookUiHelper = new UiLifecycleHelper(getActivity(), fbSessionCallback);
facebookUiHelper.onCreate(savedInstanceState);
where fbSessionCallback has overridden call()
method, that calls my onFbSessionRestore()
:
if (pendingPublishReauthorization &&
state.equals(SessionState.OPENED_TOKEN_UPDATED)) {
pendingPublishReauthorization = false;
// do things with my new session, updated with granted permission. e.g. post to fb.
}
Trouble is that
- onActivityResult executes, but after that no callback ever called, so that overridden call() won't go, and onFbSessionCallback either.
- If I try to post again (start things from scratch) after that - it gets session without granted permission again, tries to request it and then goes facebook exception about pending newPublishRequest permission blah-blah
Can someone help to configure workflow from onActivityResult and later? I read facebook docs and I tend to blame they are written badly. Maybe it's just me too stupid... :(((