I had an issue with an application crashing badly while opening MFMailComposeViewController
, it was working p开发者_JAVA技巧erfectly on the simulator and crashed on the device.
After spending some hours I realized that the reason was that the internal email client on the iPad I am using for testing was not set / configured - after setting an email on the device, all worked fine.
Thus my question: can I detect if the device email client was configured and valid to avoid the same crash again on devices which did not yet set their internal iPad / iPhone email client?
Just check the canSendMail class method:
if ([MFMailComposeViewController canSendMail]) {
// Yes we can send mail.
}
What I do is check the method and only display the mail option if it return true.
精彩评论