【问题标题】:React-Native share content to social mediaReact-Native 将内容分享到社交媒体
【发布时间】:2020-11-13 08:58:32
【问题描述】:

我正在使用Share 组件来向社交媒体分享一些数据,但我不知道如何分享像 vinted 应用程序这样的图像(cf image)。

onShare = async () => {
        try {
          const result = await Share.share({
            title: "Mariez-Vous",
            message:
            `Photo partagée : ${this.props.navigation.state.params.photo}
            Nom : ${this.props.navigation.state.params.societe}
            Site web : https://www.mariezvous.fr/`,
          });
          if (result.action === Share.sharedAction) {
            if (result.activityType) {
              // shared with activity type of result.activityType
            } else {
              // shared
            }
          } else if (result.action === Share.dismissedAction) {
            // dismissed
        }
       } catch (error) {
         alert(error.message);
      }
   };

这是我正在使用的代码,但图像没有显示它只是传递一个 url。

【问题讨论】:

    标签: react-native share


    【解决方案1】:

    您应该将 OpenGraph 元标记添加到您共享的网站。然后机器人将为您显示图像。

    一个例子:

    <meta property="og:url" content="http://www.nytimes.com/2015/02/19/arts/international/when-great-minds-dont-think-alike.html" />
    <meta property="og:type" content="article" />
    <meta property="og:title" content="When Great Minds Don’t Think Alike" />
    <meta property="og:description" content="How much does culture influence creative thinking?" />
    <meta property="og:image" content="http://static01.nyt.com/images/2015/02/19/arts/international/19iht-btnumbers19A/19iht-btnumbers19A-facebookJumbo-v2.jpg" />
    

    更多信息:https://ogp.me 和 https://developers.facebook.com/docs/sharing/webmasters

    【讨论】:

      猜你喜欢
      • 2019-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多