LaVOZs

The World’s Largest Online Community for Developers

'; Share video on facebook using react-native-fbsdk - LavOzs.Com

I tried to share a link, it works and shows the dialog with the link. I tried to share a photo, it works and shows the dialog with the picture. I tried to share an mp4 video, it doesn't work and ShareDialog.show returns null without any other information. I have used the following code to share a video on Facebook.

    const SHARE_VIDEO_CONTENT = {
    contentType: 'video',
    video: { localUrl: videoFilePath },
  }

shareVideoWithDialog = async () => {
    const canShow = await ShareDialog.canShow(SHARE_VIDEO_CONTENT);
    if (canShow) {
      try {
        const {isCancelled, postId} = await ShareDialog.show(
          SHARE_VIDEO_CONTENT,
        );
        if (isCancelled) {
          Alert.alert('Share cancelled');
        } else {
          Alert.alert('Share success with postId: ' + postId);
        }
      } catch (error) {
        Alert.alert('Share fail with error: ' + error);
      }
    }
  };
Related
Hide keyboard in react-native
How to do logging in React Native?
What is the difference between using constructor vs getInitialState in React / React Native?
React Native android build failed. SDK location not found
What is the difference between React Native and React?
Share an image with react-native-fbsdk?
React Native Facebook Login using official fbsdk
react-native-fbsdk close button returning postId = null instead of isCancelled = true
Share video with react-native-fbsdk