MailComposer breaks on iOS

#1

Hello,

I am trying to send an attachment with the composeAsync method of MailComposer, this is working on Android, but fails on iOS with the following error:

*** -[NSPlaceholderString initWithString:] nil argument

The way I call the function is

MailComposer.composeAsync({
		recipients: [ user.email ],
		subject: `Exporting ${ document.filename }`,
		body: 'This is a file exported by app',
		attachments: [
			`${ FileSystem.cacheDirectory }${ document.filename }`,
		],
	})

the file exists (checked with FileSystem.getInfoAsync). I use the cacheDirectory instead of documentDirectory
as I found a discussion mentioning that MailComposer cannot access documentDirectory, but this does not solve my problem. As mentioned, the same piece of code works correctly on Android

Any help, will be greatly appreciated. Thank you.

#2

Hey @pierref,

This certainly seems like it has the makings of a bug. Do you think you could create a github issue for this here: https://github.com/expo/expo/issues that has a way to reproduce the error either via github repo or more ideally a Snack?

Cheers,

Adam

#3

Hello @adamjnav
Sadly MailComposer is explicitly disabled on Snack. In the meantime, I have narrowed down the origin of the problem: the red screen happens when trying to attach using an uri which filename has no extension. Adding any extension when naming the file makes the mailer opens correctly.

I have created a small code to demonstrate the problem and posted it when opening this issue:

All the best
Pierre —

closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.