当应用程序已/未安装时,Facebook ShareDialog 的行为异常?

5
我正在使用Facebook的ShareDialog在我的应用程序中分享打印屏幕图像到Facebook。
当Facebook应用程序已安装时,它可以正常工作。
但是当Facebook应用程序未安装时,它无法正常工作。我看到“加载”屏幕然后消失,什么也没有发生。 Share Dialog对象会触发FacebookException的onError回调函数。
{FacebookGraphResponseException: (#200) Requires extended permission: publish_actions httpResponseCode: 403, facebookErrorCode: 200, facebookErrorType: OAuthException, message: (#200) Requires extended permission: publish_actions}

所以我只需要在 Facebook 网页版而不是 Facebook 应用程序中获得“publish_actions”权限吗?这很奇怪。
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."

我的代码:

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);
    }

为什么在没有安装“publish_actions”权限的情况下安装Facebook应用程序时可以正常工作,而不安装Facebook应用程序时不能正常工作?
1个回答

1

这是SharePhotoContent的要求,您必须安装原生Facebook应用程序才能分享照片。

来源于Facebook文档

照片

人们可以使用共享对话框或自定义界面从您的应用程序将照片分享到Facebook。

  • 照片大小必须小于12MB
  • 人们需要安装Android版原生Facebook应用程序,版本为7.0或更高版本

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接