aarajput / wc_flutter_share

A Flutter plugin for sharing files & text with other applications.
Apache License 2.0
35 stars 19 forks source link

ios: trying to save shared image closes app without error #19

Closed esskar closed 4 years ago

esskar commented 4 years ago

I am trying to save the image that i am sharing on iOS. The app crashes without notification/error

void _onSharePressed() async {
    try {
      final boundary =
          _qrCodeKey.currentContext.findRenderObject() as RenderRepaintBoundary;
      final image = await boundary.toImage(pixelRatio: 3);
      final byteData = await image.toByteData(format: ImageByteFormat.png);
      await WcFlutterShare.share(
          sharePopupTitle: 'share',
          subject: 'This is subject',
          text: 'This is text',
          fileName: 'test.png',
          mimeType: 'image/png',
          bytesOfFile: byteData.buffer.asUint8List());
    } catch (e) {
      print('error: $e');
    }
  }

Choosing to send the image by email, instagram, whatsapp works without problems. Saving to files works as well. Only save image crashes.

iPhone 8, ios 13.4.1

aarajput commented 4 years ago

Thanks for pointingout this issue, i just checked. It is crashing. I am looking into this.

akshatjagga commented 4 years ago

Have you set the required field in info.plist?

aarajput commented 4 years ago

@akshatjagga !! What fields ?

imdangle commented 4 years ago

@aarajput @esskar you should declare 2 fields in Info.plist to grant permission to access ios's library. It's only happend when build app for ios >= 10 or 11.

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Message</string>    
<key>NSPhotoLibraryUsageDescription</key>   
<string>Message</string>
aarajput commented 4 years ago

Thanks for your help @lehaidangdev . I will add this in documentation.

esskar commented 4 years ago

works. thanks. (Y)