Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

detect if the iPhone / iPad email client was configured / valid

I had an issue with an application crashing badly while opening MFMailComposeViewController, it was working perfectly 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?

like image 419
chewy Avatar asked Oct 04 '11 11:10

chewy


1 Answers

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.

like image 143
rckoenes Avatar answered Nov 12 '22 23:11

rckoenes