gpt4 book ai didi

ios - 我如何导致 MFMailComposeResultFailed 错误

转载 作者:行者123 更新时间:2023-11-29 01:51:13 25 4
gpt4 key购买 nike

我想测试我在电子邮件发送失败时所做的某种行为,但我无法得到 MFMailComposeResultFailed 错误。即使没有互联网连接,它仍然会“发送”电子邮件。如何做到这一点?

最佳答案

这是不可能的,因此委托(delegate)不会传递这种“错误”。这是有道理的,因为“邮件”负责发送或排队邮件。

来自文档(MFMailComposeViewController)

Using this interface does not guarantee immediate delivery of the corresponding email message. The user may cancel the creation of the message, and if the user does choose to send the message, the message is only queued in the Mail application outbox. This allows you to generate emails even in situations where the user does not have network access, such as in airplane mode. This interface does not provide a way for you to verify whether emails were actually sent.

您可以在显示 MFMailComposeViewController 之前检查互联网连接。这是技术上可行的,但不推荐。如果设备再次连接到互联网,Mail 将自动发送邮件。

但是您必须检查设备是否配置为发送邮件:

if ([MFMailComposeViewController canSendMail]){
//show MFMailComposeViewController
}else{
//show AlertView
}

Before using this class, you must always check to see if the current device is configured to send email at all using the canSendMail method. If the user’s device is not set up for the delivery of email, you can notify the user or simply disable the email dispatch features in your application. You should not attempt to use this interface if the canSendMail method returns NO.

https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMailComposeViewController_class/#//apple_ref/c/tdef/MFMailComposeResult

关于ios - 我如何导致 MFMailComposeResultFailed 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31392437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com