Share photo to Instagram from React-Native app built with Expo SDK

前端 未结 4 1415
南笙
南笙 2020-12-29 17:17

I want my react-native app to share a photo with Instagram. I know it\'s possible when writing in native code to open up Instagram\'s filter screen with a specified photo.

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-29 17:32

    Here is how to share a file from a remote url: download it first! :)

      const downloadPath = FileSystem.cacheDirectory + 'fileName.jpg';
      // 1 - download the file to a local cache directory
      const { uri: localUrl } = await FileSystem.downloadAsync(remoteURL, downloadPath);
      // 2 - share it from your local storage :)
      Sharing.shareAsync(localUrl, {
        mimeType: 'image/jpeg',            // Android
        dialogTitle: 'share-dialog title', // Android and Web
        UTI: 'image/jpeg'                  // iOS
      });
    

提交回复
热议问题