if (MFMessageComposeViewController.canSendText())
{
let controller = MFMessageComposeViewController()
controller.body = ""
controller.recipients = ["1234567890"]
controller.messageComposeDelegate = self as? MFMessageComposeViewControllerDelegate self.present(controller, animated: true, completion: nil)
}
else
{
print("Cannot send the message")
}
func messageComposeViewController(controller: MFMessageComposeViewController!, didFinishWithResult result: MessageComposeResult)
{
//Displaying the message screen with animation.
self.dismiss(animated: true, completion: nil)
}
while sending sms i need to attach 2 pdf i know how to add on mail but for sms i haven't found any documentation. i have used this way for mail but how to do on messaging.
func sendEmail() {
if MFMailComposeViewController.canSendMail() {
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
mail.setSubject("Invoice PDF")
do {
let attachmentData = NSData(contentsOfFile: pdfFilePath)
mail.addAttachmentData(attachmentData! as Data, mimeType: "application/pdf", fileName: "InvoicePDF")
mail.mailComposeDelegate = self
present(mail, animated: true)
}
} else {
// show failure alert
}
}