Hi,
I'm able to send emails with NSSharingService from my Swift-code app but if a user discards the email that has been condtructed and passed to Mail instead of clicking Send the didFailToShareItems method isn't called in the delegate. To set up the serivce I use:
if let sharingService: NSSharingService = NSSharingService.init(named: NSSharingServiceNameComposeEmail) {
let emailMessage: String = "An email message. The content is here...."
sharingService.recipients = [clientEmail]
sharingService.subject = "An email from myApp"
sharingService.delegate = self
if sharingService.canPerform(withItems: [emailMessage, invoiceURL]) {
sharingService.perform(withItems: [emailMessage, attachmentURL])
} else {
//notify user
}
}
The delegate's methods are:
func sharingService(_ sharingService: NSSharingService, didFailToShareItems items: [Any], error: Error) {
Swift.Print("Oops, failed to send.") //or something more constructive
}
func sharingService(_ sharingService: NSSharingService, didShareItems items: [Any]) {
Swift.Print("Sent.") //or something more constructive
}
Is there any way for my app to be informed of a Cancel action in Mail?
Thanks,
Todd.