如何使用 react-native-share 共享多个文件

How to share multiple files with react-native-share

我正在做我的项目,我需要的是实现一种通过 react-native-share 或任何其他模块发送多个文件的方法

<TouchableOpacity
  onPress={() => {
    const pathUrl = "file://"+this.state.pdfInfo[0].path
    Share.open({
      url: [pathUrl, pathUrl]
    })
      .then((res) => {
        console.log(res);
    })
      .catch((err) => {
        console.log(err);
    });
  }}
  style={{marginRight:20}}
>
  <Icon name="md-share-social" size={25} color="black"/>
</TouchableOpacity>

当用户按下此图标时,它应该与数组中的多个文件共享。但是,由于 react-native-share 需要这样的字符串,我们该如何去做呢???

还有其他方法吗??

只需将 url 替换为 urls

<TouchableOpacity
  onPress={() => {
    const pathUrl = "file://"+this.state.pdfInfo[0].path
    Share.open({
      urls: [pathUrl, pathUrl]
    })
      .then((res) => {
        console.log(res);
    })
      .catch((err) => {
        console.log(err);
    });
  }}
  style={{marginRight:20}}
>
  <Icon name="md-share-social" size={25} color="black"/>
</TouchableOpacity>