react-native-email-link: Specifying subject in openComposer throws an error when selecting Default mail reader on iOS

As the title says I’m trying to compose an email using this library with subject and body, but when selecting the Default mail reader it throws an error: [Error: Unable to open URL: file:///private/var/containers/Bundle/Application/23727D6B-B7ED-4C2F-BE2E-85F06F2F9D77/Example.app/mailto:...%3Fsubject=Mobile%20application%20customer%20support. Add file to LSApplicationQueriesSchemes in your Info.plist.]

When I select for example Gmail, it works correctly

If I remove the subject, it works even with the Default mail reader

This is how I’m calling the method

openComposer({
     body,
     subject,
     title: '',
     message: t('modals.email_app.dialog.text'),
     cancelLabel: t('buttons.cancel', {ns: 'general'}),
     to: `mailto:${url}`
   }).catch(() => {
     Alert.alert(t('modals.email_app.title'), t('modals.email_app.text'))
   })

I tried using the default Linking API with mailto:email@email.com?cc=$subject=${subject}&body=${body}and it is resulting in the same error

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 15 (2 by maintainers)

Most upvoted comments

@karel-suchomel-ed @giacomoalonzi @martinblampied I’ve made small investigation. Incorrect encoding is the root of this issue. So you can simply encode your subject and body using encodeURIComponent() if your platform is iOS.

openComposer({ to: Emails.SUPPORT_EMAIL, subject: Platform.OS === 'ios' ? encodeURIComponent(yourSubject) : yourSubject, body: Platform.OS === 'ios' ? encodeURIComponent(yourBody) : yourBody, });

Or you can use ‘encodeBody: true’ if you have problems with body

Any update about this? I’ve installed the latest release of this lib but nothing has changed.

@tschoffelen I had mailto in my plist but still have the same issue. I also added file as per the error message but that didn’t fix.

Appears to be something with the subject/body. If I only populate the ‘to’ it works. If I add a subject or body it fails.

the same

react-native version: 0.71.1