2 years ago

#71690

test-img

Menna Magdy

How to share a qr code image using expo-sharing?

I generate a qrcode using 'react-native-qrcode-svg' <QRCode size={100} value={deepLink} getRef={(c) => (svg = c)} />and I want to share the QR image using expo sharing, I tried this way but didn't work, gives me this error when sharing [Unhandled promise rejection: Error: Only local file URLs are supported (expected scheme to be 'file', got 'data'.] I have a share button that calls this function

var svg: any;
 let openShareDialogAsync = async () => {
    if (!(await Sharing.isAvailableAsync())) {
      alert(`Uh oh, sharing isn't available on your platform`);
      return;
    }
    svg.toDataURL((link: any) => {
      console.log(link);//the base64 string
      Sharing.shareAsync('data:image/png;base64,' + link);
     
    });
  };

I'll appreciate it If someone can help me with it. I tried using react-native-share but didn't work with expo, I believe I need to eject the project in order to work with it.

react-native

expo

qr-code

0 Answers

Your Answer

Accepted video resources