I'm using the ShareDialog of Facebook in order to share a printScreen image on facebook within my app.
When Facebook app is installed, it works alright.
When Facebook app isn't installed, it doesn't work. I see the "loading" screen and then it's disappeared and nothing happens. The share dialog object reaches onError callback with the FacebookException:
{FacebookGraphResponseException: (#200) Requires extended permission: publish_actions httpResponseCode: 403, facebookErrorCode: 200, facebookErrorType: OAuthException, message: (#200) Requires extended permission: publish_actions}
So do I really need "publish_actions" permission only for facebook web and not for facebook app? weird..
Facebook writes:
https://developers.facebook.com/docs/sharing/android
"If the Facebook app is not installed it will automatically fallback to the web-based dialog"
"Now the SDK automatically checks for the native Facebook app. If it isn't installed, the SDK switches people to their default browser and opens the Feed Dialog."
my code:
mShareDialog = new ShareDialog(mActivity);
mShareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {}
@Override
public void onCancel() {}
@Override
public void onError(FacebookException error) {
if (error != null) {
showDialog("facebook app isn't installed");
}
}
});
if (ShareDialog.canShow(ShareLinkContent.class)) {
// get a screenshot
Bitmap image = getScreenshot();
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.setCaption(getResources().getString(R.string.shareBodyText))
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
mShareDialog.show(content);
}
So why does it work when facebook app is installed without the "publish_actions" and doesn't work when facebook app isn't installed?
It's a requirement of the SharePhotoContent, you must have installed the native faceboook app in order to share photos.
From Facebook Docs
Photos
People can share photos from your app to Facebook with the Share Dialog or with a custom interface.
- The photos must be less than 12MB in size
- People need the native Facebook for Android app installed, version 7.0 or higher
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