Prepopulates emails with support information in iOS apps
SupportEmail 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 Countdowns or Recurrence to see SupportEmail in action.
- Xcode 10.2+
- iOS 10.0+
- Swift 5.0+
The preferred installation method is with Swift Package Manager. Starting with Xcode 11, you can add packages directly from the IDE.
You can also install with CocoaPods. To do so, add the following to your Podfile:
pod 'SupportEmail', '~> 4.0'
You can also install with Carthage. To do so, add the following to your Cartfile:
github "schayes04/SupportEmail"
Due to how MFMailComposeViewController works, you must retain a reference to SupportEmail outside of where you are sending the email.
var supportEmail: SupportEmail?
Using SupportEmail is simple and has just one method. send
will allow you to craft the email and handle the end result:
supportEmail = SupportEmail()
supportEmail.send(to: ["support@test.com"], 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
SupportEmail also supports providing custom arguments.
supportEmail.customFields = ["Pro Upgrade": "Yes"]
SupportEmail 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"
SupportEmail allows you to provide a tintColor in order to customize the appearance of the navigation bar.
supportEmail.tintColor = .blue
SupportEmail allows you to provide a baseLocale in order to localize the system locale in the email. Defaults to en-US.
supportEmail.baseLocale = Locale(identifier: "es-US")
SupportEmail allows you to provide a bodyPrefix that adds a default body to the email
supportEmail.bodyPrefix = "Please add any relevant feedback:\n"
SupportEmail allows you to change the modalPresentationStyle. Defaults to .fullScreen.
supportEmail.modalPresentationStyle = .formSheet
This code is distributed under the terms and conditions of the MIT license.