Basic sharing via email client


      let shareemail = ""
      let sharesubject = "Get the Powerball Advantage App!"
      if MFMailComposeViewController.canSendMail() {
        let mailComposerVC = MFMailComposeViewController()
        mailComposerVC.mailComposeDelegate = self
        mailComposerVC.setMessageBody("Get it now in the Apple App Store!<br><br>", isHTML: true)
        self.present(mailComposerVC, animated: true, completion: nil)
      } else {
        let coded = "mailto:\(shareemail)?subject=\(sharesubject)&body=Get it now in the Apple App Store!%0A%0A".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
        if let emailURL = URL(string: coded!){
          if UIApplication.shared.canOpenURL(emailURL){
  , options: [:], completionHandler: { (result) in
              if !result {
                // show some Toast or error alert
                //("Your device is not currently configured to send mail.")

Written by fbrefere001

Posted by fbrefere001 on Thursday February 8, 2018