send email to contact developer
This commit is contained in:
parent
95de38988b
commit
b97500ed1e
2 changed files with 28 additions and 4 deletions
|
|
@ -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: "https://mssun.me"],],
|
||||
[.type: CellDataType.link, .title: "Contact Developer", .link: "mailto:bob@mssun.me&subject=passforiOS"],],
|
||||
|
||||
// section 1,
|
||||
[[.type: CellDataType.segue, .title: "Open Source Components", .link: "showOpenSourceComponentsSegue"],
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
import UIKit
|
||||
import SafariServices
|
||||
import MessageUI
|
||||
|
||||
|
||||
enum CellDataType {
|
||||
case link, segue, empty
|
||||
|
|
@ -17,7 +19,7 @@ enum CellDataKey {
|
|||
case type, title, link, footer, accessoryType, detailDisclosureAction, detailDisclosureData
|
||||
}
|
||||
|
||||
class BasicStaticTableViewController: UITableViewController {
|
||||
class BasicStaticTableViewController: UITableViewController, MFMailComposeViewControllerDelegate {
|
||||
var tableData = [[Dictionary<CellDataKey, Any>]]()
|
||||
var navigationItemTitle: String?
|
||||
|
||||
|
|
@ -67,10 +69,32 @@ class BasicStaticTableViewController: UITableViewController {
|
|||
performSegue(withIdentifier: link!, sender: self)
|
||||
case .link:
|
||||
let link = cellData[CellDataKey.link] as! String
|
||||
let svc = SFSafariViewController(url: URL(string: link)!, entersReaderIfAvailable: false)
|
||||
self.present(svc, animated: true, completion: nil)
|
||||
let url = URL(string: link)!
|
||||
switch url.scheme! {
|
||||
case "mailto":
|
||||
sendEmail(toRecipients: [URLComponents(string: link)?.path ?? ""])
|
||||
case "http", "https":
|
||||
let svc = SFSafariViewController(url: URL(string: link)!, entersReaderIfAvailable: false)
|
||||
self.present(svc, animated: true, completion: nil)
|
||||
default:
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
func sendEmail(toRecipients recipients: [String]) {
|
||||
let mailVC = MFMailComposeViewController()
|
||||
mailVC.mailComposeDelegate = self
|
||||
print(recipients)
|
||||
mailVC.setToRecipients(recipients)
|
||||
mailVC.setSubject("Subject for email")
|
||||
mailVC.setMessageBody("Email message string", isHTML: false)
|
||||
self.present(mailVC, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
|
||||
controller.dismiss(animated: true)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue