react-native-share: Permission denied for the attachment

Hey and thank you for your amazing work. Basically I am trying to send an attachment through email but I am getting a Permission deined for the attachment error on Android.

On iOS the path just gets written after message body…

The file Im trying to send is a vcf file (VCard), the url Im trying to send looks like this: file:///data/user/0/com.appName/files/Teste-ABC.vc

my shareOptions object:

shareOptions: {
    title: 'Share VCard',
    url: `file://${file}`,
    type: 'vcf',
    message: 'VCard Test'
},

And, Im using the shareSingle option like this:

Share.shareSingle(Object.assign(shareOptions, {
    "social": "email"
}));

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

permission denied for attachment react native

@avencat Removing type from options is working as intended 👍

@RUIFERNANDE5 Ok thank you, but I tried text/xcard and my test Android phone won’t show the sms/mms option so, according to this page, I put text/x-vcalendar and it works for my case so I think I’ll let as it… 😉

Thank you for sharing with me on that issue, have a good day! 😄

@RUIFERNANDE5 I was able to solve the problem by using rnfs.ExternalStorageDirectoryPath thank you for the solution! 😃 I also wondered if you know how to share a vcf via MMS? (When I click on message, I get an error saying that files must be shared via MMS and not SMS… (On Android)

Thank you for your time! 😃

I was able to solve this on android by saving the file on ExternalStorageDirectoryPath. Im not using react-native-share on iOS anymore, although If im correct it worked when I first created a Dir and then generated the file inside that Dir.