Check if user has email set up on their iDevice?

2020-07-06 06:58发布

问题:

How do you check (programmatically) if a user has set up an email account in Mail.app. It seems to be causing a crash.

Cheers

回答1:

if ([MFMailComposeViewController canSendMail]) {
    [self doStuff];
}


回答2:

Class mailClass =(NSClassFromString(@"MFMailComposeViewController"));
if(mailClass!=nil)
{
    if ([mailClass canSendMail]) 
    {

        [self displayMailComposerSheet]; 
       //compose box
    }else
    {
       //email account not setup on the device.
    }
}else 
{
 // problem in loading mail setup.

}