MFMailComposeViewController can send a notification of a change in sending if no is returned

I use MFMailComposeViewController canSendMail in my application, everything works fine, but if there are no accounts on the iPhone or iPad, it returns the standard warning that I would like to change. If I put a warning in another, it will return 2 warnings. Is there a way to change the standard warning it returns? Or at least change the text in it?

MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; if ([MFMailComposeViewController canSendMail]) { controller.mailComposeDelegate = self; controller.navigationBar.tintColor = [UIColor grayColor]; NSArray *toRecipients = [NSArray arrayWithObject:@" info@info.nl "]; [controller setToRecipients:toRecipients]; [controller setSubject:@"bericht van info"]; [self presentModalViewController:controller animated:YES]; [controller release]; } else { } 
+6
source share
3 answers

try one thing. Move the initialization code MFMailComposeViewController inside the canSendMail block.

+10
source

Move 'MFMailComposeViewController' selection inside if:

 if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; controller.mailComposeDelegate = self; controller.navigationBar.tintColor = [UIColor grayColor]; NSArray *toRecipients = [NSArray arrayWithObject:@" info@info.nl "]; [controller setToRecipients:toRecipients]; [controller setSubject:@"bericht van info"]; [self presentModalViewController:controller animated:YES]; [controller release]; } else { // Display custom alert here. } 
+4
source

You can check if the device can send email with

[MFMailComposeViewController canSendMail]

And if not, show the dialogue on your side

0
source

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


All Articles