如何在iOS上共享本机图像和消息?

时间:2019-05-17 11:01:39

标签: ios react-native share react-native-ios

我正在尝试与react-native-share和Share库共享屏幕快照图像并下载该应用程序的链接。 Android仅在iOS仅适用于WhatsApp的问题上运行良好。如果有人有解决方案,请告诉我。

这是我的代码:

<ScrollView ref='Sc' collapsable={false}>
          <View collapsable={false} ref={(shot) => { this.screenshot = shot; }} style={styles.innerContainer}>
            <Image source={{uri : this.state.imageURI}} style={{width: 200, height: 300, resizeMode: 'contain', marginTop: 5}} />

            <TouchableOpacity style={styles.shareBtn}
              onPress={this.captureScreenss.bind(this)}>
              <Icon style={styles.iconStyle} name="ellipsis-h" size={22} color="#fff" />
              <Text style={styles.shareText}>More</Text>
             </TouchableOpacity>

          </View>
        </ScrollView>

功能如下:

captureScreenss = () => {
     captureRef(this.refs.Sc, {
       format: 'jpg',
       quality: 0.8,
       result: 'base64',
       snapshotContentContainer: true
     })
       .then(res => {
         console.log("return data",res);
         this.setState({ imageURI:res });
         const shareOptions = {
          title: 'Title',
          message: "Download ."+ "\n" + "Download link: https://github.com/react-native-community/react-native-share", // Note that according to the documentation at least one of "message" or "url" fields is required
          url: "data:image/jpg;base64,"+res,
          subject: 'Subject'
        };
        Share.share(shareOptions);

       }).catch(error => {
         console.log(error, 'this is error')
       })
   }

请让我知道是否有人对此有解决方案。

0 个答案:

没有答案