react-native-share / react-native-share

Social share, sending simple data to other apps.

Home Page:https://react-native-share.github.io/react-native-share

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to Share Multiple Files with Different Formats via Whatsapp on IOS

saikrishnagudipudiextwebtech opened this issue · comments

Issue Summary

When attempting to share multiple files of different formats (such as VCF and image files) simultaneously via WhatsApp on iOS using the react-native-share package, the sharing process fails. This issue arises specifically when using the Share.open() method with the urls parameter containing URLs of the files to be shared.

Steps to reproduce

1.Implement a React Native application using the 'react-native-share' package
2. Attempts to share multiple files (e.g., a VCF file and an image file) via WhatsApp on ios at a time
3. Use the 'Share.open()' method with the 'urls' parameter containing URLs of the files.
4. Observe the WhatsApp fails to handle the shared files properly

Expected behavior

WhatsApp on IOS should be able to handle the sharing of multiple files of different formats simultaneously when using the 'react-native-share' package

Actual behavior

WhatsApp on iOS fails to properly handle the shared files, resulting in an unsuccessful sharing process.

Environment

  • React Native version: 0.61.3
  • Typescript version (if using typescript): 3.8+ required, what version is in your environment?

react-native-share

Version: 7.3.0

Link to repo (highly encouraged)

shareVCardAndQRCode = async () => {
let jpgImage = null;
let vCardDetail = vCardsJS();
vCardDetail.firstName = "John";
vCardDetail.lastName = "abc";
vCardDetail.workPhone = "+919999999999";
vCardDetail.url = "";
vCardDetail.email = "abc@gmail.com";
vCardDetail.organization = "abc";
let path = RNFS.CachesDirectoryPath + '/shareCard.vcf';
vCardDetail.saveToFile(path);

//using RNFS blob
let base64Image = '';
let imagePath = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQHJU-UAZ8Dg9RHVdn6hA9B5gjI8VfAuy0xUESg4HWGOA&s"
let imageUrl = imagePath;
RNFetchBlob
  .fetch('GET', imageUrl, {
  })
  .then(async(res) => {
    imagePath = res.path()
    base64Image = res.base64()
    
    try {
      RNFetchBlob
      .fetch('GET', imageUrl, {
      })
      .then(async(res) => {
        imagePath = res.path()
        base64Image = res.base64()
        
        try {
          await Share.open({
            message: '',
             urls:['data:image/png;base64,'+ base64Image, 'file://' + path, ],
              type: 'application/vcf',
          });

        } catch (err) {
          console.log("first", err)
        }
       
      })
    } catch (err) {
      console.log("error", err)
    }
  })  

}