BeTomorrow/react-native-file-logger

sendLogFilesByEmail not working on iPhone

Closed this issue · 3 comments

Can you support other mail composer to send emails other than native one on iphone? I think it is fine for users to leave app when sending log file since they can come back after that. It really confuses users when they click on 'send logs' button but nothing happens, or at least it should throw an error that the Mail app is not configured or something like that.

Hello,

Unfortunately the only way to send mail with attachment programmatically on iOS is to use MFMailComposeViewController the default mail client. Apple does not provide any method to adapt to other mail clients (gmail for example).

Internally the lib calls the method MFMailComposeViewController.canSendMail() and if the response if false it throws the exception Cannot send emails on this device.

We have some apps using this library and in this case we try/catch the call to FileLogger.sendLogFilesByEmail() and display a message to the user if there is an exception.

In any case you can always have access to the files directly using FileLogger.getLogFilePaths() and react-native-fs and do whatever you want with the log files.

Hi, thanks for reply. Do you mean in the latest version of this library, it would display a error message to user rather than do noting if user never enroll a native mail account?

If the default mail client is not available it throws the exception Cannot send emails on this device.

It is up to you to catch the exception and present an error message to the user.