I have an app where I am trying to get the Mail composer to open when one of the menu items is clicked. Unfortunately, the compose mail window only shows up momentarily and then disappears. This problem started after I upgraded to xcode 11.
I get the following errors when I click the menu item that triggers the mail composer.
2019-10-27 23:36:17.739375-0700 Favor Circle[14048:72257] [Common] [FBSSystemService][0x7259] Error handling open request for com.apple.MailCompositionService: <NSError: 0x6000038da820; domain: FBSOpenApplicationServiceErrorDomain; code: 1 (RequestDenied); reason: "The request was denied by service delegate (SBMainWorkspace) for reason: Security ("Entitlement "com.apple.frontboard.launchapplications" is required to open applications in this manner")."> {
userInfo = {
FBSOpenApplicationRequestID = 0x7259;
}
underlyingError = <NSError: 0x6000038daa00; domain: FBSOpenApplicationErrorDomain; code: 3 (Security); reason: "Entitlement "com.apple.frontboard.launchapplications" is required to open applications in this manner.">;
}
2019-10-27 23:36:17.739683-0700 Favor Circle[14048:72256] [Assert] Connection request invalidated without resuming our _serviceSessionConnection. This is an error.
2019-10-27 23:36:17.739902-0700 Favor Circle[14048:65051] [General] #CompositionServices _serviceViewControllerReady: NSError Domain=_UIViewServiceInterfaceErrorDomain Code=0
How do I enable the required entitlements?
I have already lost two days over this problem. Please help.
I am adding the code below. This snippet is from the side menu.
case "Edit Profile":
if MFMailComposeViewController.canSendMail() {
//print ("Attempting to send email")
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
mail.setToRecipients(["support@myfavorcircle.com"])
mail.setSubject("MyFavorCircle team, please update my profile")
var message = "Please tell us what information you need updated<br><br><br><p>My userid is: "
message.append(Auth.auth().currentUser!.email!)
message.append("</p>")
mail.setMessageBody(message, isHTML: true)
present(mail, animated: true)
}
else
{
print ("No email account on device")
}
This snippet is to dismiss the compose controller.
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
switch result.rawValue {
case MFMailComposeResult.cancelled.rawValue :
print("Cancelled")
case MFMailComposeResult.failed.rawValue :
print("Failed")
case MFMailComposeResult.saved.rawValue :
print("Saved")
case MFMailComposeResult.sent.rawValue :
print("Sent")
default: break
}
When I run through the code, I get 'Cancelled' on the log console even though I did not press cancel on the composer. I am guessing it is due to the above error.