Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFMailComposeViewController error [MC] Filtering mail sheet accounts for bundle ID

I do the standard functionality of sending messages with MFMailComposeViewController.

My code:

if MFMailComposeViewController.canSendMail()
{
    let mail = MFMailComposeViewController()
    mail.mailComposeDelegate = self
    mail.setToRecipients(["[email protected]"])
    mail.setSubject("Subject")
    mail.setMessageBody("Some Text", isHTML: false)
    self.presentViewController(mail, animated: true, completion: nil)
}

Controller do not open and I see a message in the console that have never seen.

[MC] Filtering mail sheet accounts for bundle ID: [My Bundle ID], source account management: 1

[MC] Result: NO

Help please.

like image 587
Владимир Буковский Avatar asked Nov 15 '16 11:11

Владимир Буковский


2 Answers

If a mail account has been set at the device where you try to test your application there is no problem. Please create a mail account.

like image 135
Hope Avatar answered Oct 19 '22 02:10

Hope


For Swift 3.0.1 - 4.2 Compatible

if MFMailComposeViewController.canSendMail()
{
    let mail = MFMailComposeViewController()
    mail.mailComposeDelegate = self
    mail.setToRecipients(["[email protected]"])
    mail.setSubject("Subject")
    mail.setMessageBody("Some Text", isHTML: false)
    self.present(mail, animated: true, completion: nil)
}

I had the same error though it works perfectly on my device with iOS 10.1.1. I had a similar problem and found that the Mail Composer would only work on iOS 9 in the simulator, there is some sort of bug with iOS 10 and running Mail Composer on the simulator with my current knowledge.

Update I have also tested this with a device with iOS 11.4 and got the same results.

Tried these calls to open mail on the simulator and they did not work. Though work they work fine on a real device.

UIApplication.shared.keyWindow?.rootViewController?.present(mail, animated: true)
self.navigationController?.present(mail, animated: true, completion: nil)
like image 44
uplearned.com Avatar answered Oct 19 '22 02:10

uplearned.com