使用react native在Twitter上发布/分享

时间:2017-12-28 08:25:42

标签: react-native twitter

我正在尝试在我的反应原生应用中发布/分享Twitter上的推文。但我无法找到任何正在运行的库/框架。请建议我一个完美的图书馆。提前谢谢。

2 个答案:

答案 0 :(得分:1)

//cancel method

onCancel() {
    console.log("CANCEL")
    this.setState({visible:false});
}  

    //in render method
        {
            let shareOptions = {
            title: "your app name",
            message: "Sharing Test",
            url: which url you want share,
            subject: "Share"   //  for email
          };

    // in retrun 

     <TouchableOpacity activeOpacity={.5} onPress={()=>{
              this.onCancel();
              setTimeout(() => {
               Share.shareSingle(Object.assign(shareOptions, {
                  "social": "twitter"
                }));
              },300);}}>
          <Image source={require('../images/twitter.png')} style={{resizeMode:"stretch",height:35,width:35,marginLeft:15}}/>
          </TouchableOpacity>

答案 1 :(得分:0)

您是在尝试分享已有的推文,还是想在Twitter上分享您应用中的某些内容?如果是后者,您可能需要查看https://facebook.github.io/react-native/docs/share.html