Невозможно поделиться изображением продукта в React Native Share - PullRequest
1 голос
/ 10 апреля 2020

Я работаю над тем, чтобы поделиться описанием продукта, URL-адресом и изображением, используя Reaction-native-share. Но он не работает и показывает приложение как somename.null. Я получаю изображение base64 из ответа. Код написан ниже.

shareProduct = () => {
    console.log(this.props.productDetails);
    let { name, product_url, base64 } = this.props.productDetails;

    const shareOptions = {
      title: "Testing APP",
      url: product_url,
      message: "This is the testing. Please check",
      subject: name
    };
    if( base64 !== "" && base64 !== undefined ){
      shareOptions.url = base64;
      shareOptions.type   = 'image/jpeg';
    }
    Share.open(shareOptions)
      .then(res => {})
      .catch(err => {
        console.log(err);
      });
  };

Пожалуйста, помогите мне найти проблему, в которой я ошибаюсь.

enter image description here

1 Ответ

0 голосов
/ 10 апреля 2020

Вам нужно изменить URL в настройках:

    Share.open(
      {
        message: "This is the testing. Please check",
        title: 'Share',
        url: product_url,
        type: 'image/jpg',
        activityItemSources: [
          {
            linkMetadata: {image: `data:image/jpg;base64,${product_url}`},
          },
        ],
      },
      {
        // Android only:
        dialogTitle: 'Share',
        // iOS only:
        excludedActivityTypes: ['com.apple.UIKit.activity.PostToTwitter'],
      },
    );
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...