MFMailComposeViewController "No Email Accounts" Warning Issue - SDK 3.0 vs SDK 4.0

I have a problem with this piece of code when I create it for different base SDKs:

MFMailComposeViewController *mail = nil; mail = [[MFMailComposeViewController alloc] init]; NSString *description = @"Some mail string"; if([MFMailComposeViewController canSendMail]) { mail.mailComposeDelegate =self; [mail setSubject:story.title]; [mail setMessageBody:[NSString stringWithFormat:(NSString *)kMessageBodyFormat,description,story.webLink] isHTML:NO]; } [self presentModalViewController:mail animated:YES]; [mail release]; mail=nil; 

When I create it with the base SDK 3.0, in case MFMailComposeViewController's initialization returns nil, which occurs if the user does not have mail accounts, the default "No mail accounts" notification system is launched by the system.

But when I create it with the base SDK 4.0 and deploy it for OS 3.0, if the user does not have email accounts, then the same warning is not displayed by the system, presentModalViewController fails instead.

MFMailComposeViewController's initialization returns nil if the user does not have mail accounts in both SDK 3.0 and 4.0, but somewhere presentModalViewController intelligently puts a warning in case of SDK 3.0, but SDK 4.0 deployed to 3.0 fails and fails.

Has anyone come across this problem / any ideas what is actually happening.

Thanks Raj

+4
source share
2 answers

I just did some beta tests with iOS 4 and came across your post. I could not understand why he returned, so thanks for the answer. As for the answer to your question, you just need to check to see if this is there. If it is nil then don’t imagine a modal view controller. It will still show a popup.

+7
source

I found this question while I have the same problem.

I think because if the phone does not have an email account. [[MFMailComposeViewController alloc] init] returns nil.

So, before presenting the view controller, we need to check if it is there or not.

+8
source

Source: https://habr.com/ru/post/1313412/


All Articles