facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 907 forks source link

Unable to share photo by MessageDialog #632

Closed ChristinaPopova closed 4 years ago

ChristinaPopova commented 5 years ago

🐛 Bug Report

Hi! Thanks for the awesome library! Unfortunately after upgrading react-native and react-native-fbsdk I ran into the issue related to sharing photo by MessageDialog.

To Reproduce

I have installed Facebook and Messenger applications on iPhone and Android device. The same sharePhotoContent work properly for Facebook (via ShareDialog) and return error for MessageDialog: on IOS: 'SharingContent is invalid' on Android: 'Unable to show the provided content via the web or the installed version of the Facebook app. Some dialogs are only supported starting API 14.'

Code Example

ImagePicker.launchImageLibrary({ mediaType: 'photo' }, response => {
    const sharePhotoContent = {
      contentType: 'photo',
        photos: [{ imageUrl: Platform.OS === 'android' ? 'file://' + response.path  : response.uri}],
    };
    MessageDialog.canShow(sharePhotoContent).then(
      function(canShow) {
        console.log('Share canShow');
        if (canShow) {
          return MessageDialog.show(sharePhotoContent);
        }
      }
    ).then(
      function(result) {
        if (result.isCancelled) {
          console.log('Share cancelled');
        } else {
          console.log('Share success with postId: '
            + result.postId);
        }
      },
      function(error) {
        console.log('Share fail with error: ' + error);
      }
    )
  });

Environment

System: OS: macOS 10.14.5 CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz Memory: 1.59 GB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.16.1 - /usr/local/bin/node Yarn: 1.12.1 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1 Android SDK: API Levels: 23, 24, 26, 27, 28 Build Tools: 27.0.3, 28.0.3 System Images: android-27 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.2 AI-181.5540.7.32.5014246 Xcode: 10.1/10B61 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: ^0.60.4 => 0.60.4 react-native-fbsdk: 1.0.2
gmertk commented 4 years ago

Hi ChristinaPopova, sharing to Messenger via the SDKs was deprecated a while ago. Changelog: https://developers.facebook.com/docs/messenger-platform/changelog/#20190610 Explanation in the notice card on top of https://developers.facebook.com/docs/sharing/messenger/

harleenarora commented 4 years ago

@ChristinaPopova can you solved this issue.