Good afternoon
I have a Tab Bar Item and would like it when I clicked it to trigger a UIActivityViewController that would pay for a PDF of a link ex :( link ) and I can send it as an attachment to an email.
Good afternoon
I have a Tab Bar Item and would like it when I clicked it to trigger a UIActivityViewController that would pay for a PDF of a link ex :( link ) and I can send it as an attachment to an email.
You should use the MessagesUI api to compose email to the user as follows:
import MessageUI
class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let mailComposeVC = MFMailComposeViewController()
mailComposeVC.mailComposeDelegate = self
mailComposeVC.setToRecipients(["[email protected]"])
mailComposeVC.setSubject("Assunto !!!")
mailComposeVC.setMessageBody("Texto da mensagem", isHTML: false) // também pode mandar html
// para mandar um arquivo
if let data = try? Data(contentsOf: Bundle.main.url(forResource: "nomeDoArquivo", withExtension: "pdf")!) {
print(data.count)
mailComposeVC.addAttachmentData(data, mimeType: "application/pdf", fileName: "Any Name")
}
present(mailComposeVC, animated: true)
}
}