iOS - 确保应用程序中的电子邮件通过
问题描述:
如果我有一个应用程序从应用程序内向用户朋友发送电子邮件或短信消息,我该如何检查以确保消息已通过并发送成功,或者或者没有不好的服务阻碍了成功发送消息的方式,哪些不能或者不能做到这一点?iOS - 确保应用程序中的电子邮件通过
答
要查看你的应用程序发送电子邮件的结果,应实现委托方法mailComposeController:didFinishWithResult:result:error
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
if (result == MFMailComposeResultSent) {
// email was sent successfully
} else if (result == MFMailComposeResultFailed) {
// email failed to send
NSLog(@"mail send error: %@", [error localizedDescription]);
}
}
请务必设置您的MFMailComposeViewController
到self
的委托。
当然,这只是告诉你的电子邮件是否被成功发送。真的没有办法知道收件人的邮件已交付。
SWEET!非常感谢!你知道关于同样的事情的短信吗? – 2012-03-08 06:48:16
对于短信,它基本上是一样的,除了你将使用'MFMessageComposeViewController'对象并实现'messageComposeViewController:didFinishWithResult:'委托方法。 – jonkroll 2012-03-08 07:09:05
谢谢!这是非常好的! – 2012-03-11 05:43:41