MFMailComposeViewController duplicate email

Originator:david.bucsu
Number:rdar://FB9083019 Date Originated:19/04/2021
Status:Open Resolved:
Product:macOS Catalyst Product Version:iOS 14
Classification:Unexpected behaviour Reproducible:Yes
 
Using MFMailComposeViewController for sending emails in a Mac Catalyst app sends the email twice.

I created an empty sample app to check, got the same results. The same code works fine on iOS (email only gets sent once). I use a Google account for my mailing on both platforms.

Sample code:


import UIKit
import MessageUI

class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
  override func viewDidLoad() {
    super.viewDidLoad()
  }

  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
     
    if !MFMailComposeViewController.canSendMail() {
      print("Cannot send mail")
      return
    }
    let composeVC = MFMailComposeViewController()
    composeVC.mailComposeDelegate = self
    composeVC.setSubject("Test subject")
    composeVC.setMessageBody("Test body", isHTML: false)
    self.present(composeVC, animated: true, completion: nil)
  }

  func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
    controller.dismiss(animated: true, completion: nil)
  }
}

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!