Skip to content

react-native-fbsdk ShareDialog.show promise not resolves in Android #12457

@lucianomlima

Description

@lucianomlima

Description

In my app, user selects an image, makes some modifications to the image, and then uses ShareDialog to send the processed image to his Facebook account.
I can successfully share the image, but I never get the result of the promise.
I'm trying in many ways but in all of them I don't know if it was shared successfully or canceled by the user to update the user interface accordingly.

Reproduction

My sharePhotoContent object

    const { ShareDialog } = FBSDK;
    const sharePhotoContent = {
        contentType: 'photo',
        photos: [
            {
                imageUrl: imagePath,
                userGenerated: false,
                caption: "My awesome photo"
            }
        ]
    };

Below it is all the ways I tried to get result of the promise.

    ShareDialog.canShow(sharePhotoContent).then(
        function(canShow) {
            if (canShow) {
                console.log(canShow);
                return ShareDialog.show(sharePhotoContent);
            }
        }
    ).then(
        function(result) {
            console.log(result); // This never called
            result.isCancelled
            ? shareCancel = true
            : shareSuccess = true;
        },
        function(error) {
            shareError = error.toString();
        }
    );
ShareDialog.canShow(sharePhotoContent)
    .then(canShow => {
        if (canShow) {
            console.log(canShow);
            return ShareDialog.show(sharePhotoContent);
        }
    })
    .then(result => {
        console.log(result);
        result.isCancelled
            ? shareCancel = true
            : shareSuccess = true;
    })
    .catch(error => {
        shareError = error.toString();
    });
    ShareDialog.canShow(sharePhotoContent).then(
        function(canShow) {
            if (canShow) {
                console.log(canShow);
                ShareDialog.show(sharePhotoContent)
                .then(
                    function(result) {
                        console.log(result);
                        result.isCancelled
                        ? shareCancel = true
                        : shareSuccess = true;
                    },
                    function(error) {
                        shareError = error.toString();
                    }
                );
            }
        }
    );

And even trying to call ShareDialog.show directly did not work for me.

Additional Information

In iOS works perfectly.

  • React Native version: 0.39.2
  • RN FBSDK version: 0.4.0
  • Platform: Android (tested with 5.0, 5.1, 6.0)
  • Operating System: MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions