Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add emailer helper class #11

Open
eonist opened this issue May 26, 2023 · 0 comments
Open

Add emailer helper class #11

eonist opened this issue May 26, 2023 · 0 comments

Comments

@eonist
Copy link
Member

eonist commented May 26, 2023

#if os(iOS)
import Foundation
import UIKit
/**
 * - Fixme: ⚠️️ Add for macOS as well? or is it supported as is?
 */
public class Emailer {
//   public typealias MailInitiator = UIViewController & MFMailComposeViewController
   /**
    * - Fixme: ⚠️️ Add example
    * - Parameters:
    *   - viewController: the mail vc
    *   - text: text to mail
    *   - recipient: "[email protected]"
    */
   public static func sendMail(on viewController: UIViewController/*MFMailComposeViewController*/, text: String, recipient: String) -> UIAlertAction {
      fatalError("Out of order") // - Fixme: ⚠️️ requires testing
//      UIAlertAction(title: "Send Email", style: .default) {
//         (_: UIAlertAction) in
//         DispatchQueue.main.async {
//            if MFMailComposeViewController.canSendMail() {
//               let composeVC = MFMailComposeViewController()
//               composeVC.mailComposeDelegate = viewController
//               composeVC.setToRecipients([recipient])
//               composeVC.setSubject("Console Log")
//               composeVC.setMessageBody(text, isHTML: false)
//               viewController.present(composeVC, animated: true, completion: nil)
//            } else {
//               let alert = UIAlertController(title: "Email account required",
//                                             message: "Please configure an email account in Mail",
//                                             preferredStyle: .alert)
//               alert.addAction(UIAlertAction.init(title: "OK", style: .default))
//               viewController.present(alert, animated: true, completion: nil)
//            }
//         }
//      }
   }
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant