简体   繁体   中英

Waiting until an email has been sent on iOS?

My app allows the user to send an email through MFMailComposeViewController. While the email is being sent, I'd like to display an activity indicator. Problem is I can't find a way to know when it's been sent. The delegate is only being told whether the mail was placed in the outbox:

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error

Is there any way to know whether an email has been sent on iOS?

I think you're out of luck, sort of. Once the email gets passed to the Mail app, you lose track of it, and it becomes the responsibility of the Mail app alone. And there isn't a way to even poll the Mail app to determine if an email has been sent.

But as long as the device has a network connection and the user has an email account set up, you're pretty much guaranteed the email will be sent, assuming you don't get an error returned to you. And you can always pre-check for network connectivity and email access before you attempt to present the MFMailComposeViewController.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM