From 1e07cf2e46edaddfc91ab4c2c5c83f986ed61342 Mon Sep 17 00:00:00 2001 From: Bob Sun Date: Thu, 9 Feb 2017 16:44:02 +0800 Subject: [PATCH] fix bugs in email developer function --- pass/Controllers/AboutTableViewController.swift | 2 +- pass/Controllers/BasicStaticTableViewController.swift | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pass/Controllers/AboutTableViewController.swift b/pass/Controllers/AboutTableViewController.swift index d9c52bb..126a4e6 100644 --- a/pass/Controllers/AboutTableViewController.swift +++ b/pass/Controllers/AboutTableViewController.swift @@ -14,7 +14,7 @@ class AboutTableViewController: BasicStaticTableViewController { tableData = [ // section 0 [[.type: CellDataType.link, .title: "Website", .link: "https://github.com/mssun/pass-ios.git"], - [.type: CellDataType.link, .title: "Contact Developer", .link: "mailto:bob@mssun.me&subject=passforiOS"],], + [.type: CellDataType.link, .title: "Contact Developer", .link: "mailto:bob@mssun.me?subject=passforiOS"],], // section 1, [[.type: CellDataType.segue, .title: "Open Source Components", .link: "showOpenSourceComponentsSegue"], diff --git a/pass/Controllers/BasicStaticTableViewController.swift b/pass/Controllers/BasicStaticTableViewController.swift index 7c53eb0..22dc1fd 100644 --- a/pass/Controllers/BasicStaticTableViewController.swift +++ b/pass/Controllers/BasicStaticTableViewController.swift @@ -72,7 +72,9 @@ class BasicStaticTableViewController: UITableViewController, MFMailComposeViewCo let url = URL(string: link)! switch url.scheme! { case "mailto": - sendEmail(toRecipients: [URLComponents(string: link)?.path ?? ""]) + let urlComponents = URLComponents(string: link)! + let subject = urlComponents.queryItems![0].value ?? "" + sendEmail(toRecipients: [urlComponents.path], subject: subject) case "http", "https": let svc = SFSafariViewController(url: URL(string: link)!, entersReaderIfAvailable: false) self.present(svc, animated: true, completion: nil) @@ -84,12 +86,12 @@ class BasicStaticTableViewController: UITableViewController, MFMailComposeViewCo } } - func sendEmail(toRecipients recipients: [String]) { + func sendEmail(toRecipients recipients: [String], subject: String) { let mailVC = MFMailComposeViewController() mailVC.mailComposeDelegate = self mailVC.setToRecipients(recipients) - mailVC.setSubject("Subject for email") - mailVC.setMessageBody("Email message string", isHTML: false) + mailVC.setSubject(subject) + mailVC.setMessageBody("", isHTML: false) self.present(mailVC, animated: true, completion: nil) }