react-native-mail icon indicating copy to clipboard operation
react-native-mail copied to clipboard

Success callback for android

Open rayj10 opened this issue 6 years ago • 2 comments

Hi,

First of all, thanks for the great lib, this really saved my project! Just a little question tho, is there any way I can try to trigger some sort of success callback on android upon successful email sending completion? I know the doc said android will only do the callback upon error. So I was just wondering if there is any way to find out whether user has successfully sent the email?

Thanks in advance!

UPDATE: I've done a little bit of digging into your android code, I'm assuming it's almost impossible to do callback.invoke() anywhere in RNMail.java since as soon as the mail app is triggered, react native bridge would be down already and there's no way the android code can reach my app unless it listens to app state as well from the android side. I'm very new with android so I wouldn't know how to do that. If you can point me in the right direction that would be awesome!

Please let me know if there's other obvious workaround that I missed. :)

rayj10 avatar Dec 28 '18 08:12 rayj10

I have the exact same issue myself: I need to keep a trace of any email sent through the app (with the title, content, etc...) and I would need a callback on success with this information.

Have you made any progress on this since @rayj10 ?

HZSamir avatar Jul 28 '19 15:07 HZSamir

       Mailer.mail({
                    subject: 'need help',
                    recipients: ['[email protected]'],
                    ccRecipients: [],
                    bccRecipients: [],
                    body: '<b>A test body</b>',
                    isHTML: true,
                    attachment: {
                        path: '',  // The absolute path of the file from which to read data.
                        type: '',   // Mime Type: jpg, png, doc, ppt, html, pdf, csv
                        name: '',   // Optional: Custom filename for attachment
                    }
                }, (err, event) => {
                    console.log(err, event);
                });

The email is sent successfully, but I can not get callback (err, event)

avagru avatar Feb 21 '20 15:02 avagru