Check if user has email set up on their iDevice?

2020-07-06 06:54发布

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

2条回答
来,给爷笑一个
2楼-- · 2020-07-06 06:56
if ([MFMailComposeViewController canSendMail]) {
    [self doStuff];
}
查看更多
地球回转人心会变
3楼-- · 2020-07-06 07:12
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.

}
查看更多
登录 后发表回答