0
votes

i'm using the Share component in order to share some data to social medias but i don't know to how to share an image like the vinted app (cf image). enter image description here

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);
      }
   };

Here is the code that I'm using but the image is not displaying it's only passing an url.

1

1 Answers

0
votes

You should add OpenGraph meta tags to the website your share. The bots will then show the image for you.

An example:

<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" />

enter image description here

More informations : https://ogp.me and https://developers.facebook.com/docs/sharing/webmasters