SHSupportEmail 2.4.0

SHSupportEmail 2.4.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release May 2018
SPMSupports SPM

Maintained by Stephen Hayes.



SHSupportEmail

Platform CocoaPods Swift Version

Prepopulates emails with support information in iOS apps

About

SHSupportEmail is about simplifying support for apps. By prepopulating device information in your embedded support email link, you can save time and needless back and forth between you and your users. Check out Countdown Widget to see SHSupportEmail in action.

Requirements

  • Xcode 9.0+
  • iOS 8.0+
  • Swift 4.0+

Installation

CocoaPods

The preferred installation method is with CocoaPods. Add the following to your Podfile:

pod 'SHSupportEmail', '~> 2.4.0'

Usage

Due to how MFMailComposeViewController works, you must retain a reference to SHSupportEmail outside of where you are sending the email.

var supportEmail: SHSupportEmail?

Using SHSupportEmail is really simple and has just one method. send will allow you to craft the email and handle the end result:

supportEmail = SHSupportEmail()
supportEmail.send(to: ["[email protected]"], subject: "Support", from: self) { result, error in
    switch result {
    case .cancelled:
        print("Message cancelled")
    case .failed:
        print("Message failed")
    case .saved:
        print("Message saved")
    case .sent:
        print("Message sent")
    }
}

The send function takes 3 arguments:

  • An array of email address the support email should be sent to
  • The subject of the support email
  • The view controller the MFMailComposeViewController is to be presented on

Advanced

SHSupportEmail also supports providing custom arguments.

supportEmail.customFields = ["Pro Upgrade": "Yes"]

Customization

SHSupportEmail allows you to provide choose between sending a text file or just content in the email body. Defaults to sending as a text file. If you are sending as a text file you can also specify the file name.

supportEmail.sendAsTextFile = true
supportEmail.fileName = "Sample File Name"

SHSupportEmail allows you to provide a tintColor in order to customize the appearance of the navigation bar. It also allows you to specify the status bar style.

supportEmail.tintColor = .blue
supportEmail.statusBarStyle = .lightContent

License

This code is distributed under the terms and conditions of the MIT license.