Swiftpack.co - Package - schayes04/SupportEmail
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

SupportEmail

Platform CocoaPods Swift Version

Prepopulates emails with support information in iOS apps

About

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 to see SupportEmail in action.

Requirements

  • Xcode 10.2+
  • iOS 10.0+
  • Swift 5.0+

Installation

Swift Package Manager

The preferred installation method is with Swift Package Manager. Starting with Xcode 11, you can add packages directly from the IDE.

CocoaPods

You can also install with CocoaPods. To do so, add the following to your Podfile:

pod 'SupportEmail', '~> 4.0'

Carthage

You can also install with Carthage. To do so, add the following to your Cartfile:

github "schayes04/SupportEmail"

Usage

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

Advanced

SupportEmail also supports providing custom arguments.

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

Customization

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

License

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

Github

link
Stars: 16

Releases

4.6.0 - 2020-10-30T15:33:24

  • Added iPhone 12 identifiers

4.5.0 - 2020-09-19T14:26:44

  • Added iPad Air 4th generation & iPad 8th generation identifiers

4.4.0 - 2020-05-02T15:37:19

  • Added iPhone SE 2nd generation identifier

4.3.0 - 2020-05-02T15:36:46

  • Added iPad 8th generation identifiers

4.2.0 - 2019-09-23T23:06:45

  • Added iPad 7th generation identifier

4.1.0 - 2019-09-20T23:49:54

  • Added iPhone 11, 11 Pro, & 11 Pro Max identifiers

4.0.0 - 2019-08-24T22:04:29

  • Added support for Swift Package Manager
  • Added support for Carthage
  • Added iPod Touch 7th generation identifier
  • Separated identifiers for iPod Touch based off generation
  • Moved minimum supported iOS to 10.0
  • Improved quick help documentation

3.2.0 - 2019-08-24T22:02:42

  • Added ability to change modalPresentationStyle

3.1.0 - 2019-04-22T22:59:41

  • Added device identifiers for iPad Mini 5 & iPad Air 3
  • Added ability to have default body of email

3.0.0 - 2019-03-30T17:49:06

  • Migrated to Swift 5.0

2.3.0 - 2018-11-09T02:20:37

  • Added device identifiers for iPad Pro (3rd generation)

2.2.0 - 2018-11-09T02:20:25

  • Added baseLocale setting. Email now includes device locale localized for base locale.

2.1.0 - 2018-11-09T02:20:09

  • Added device identifiers for iPhone XR, iPhone XS, and iPhone XS Max

2.0.0 - 2018-09-12T23:27:45

  • Updated to Swift 4.2
  • Removed deprecated statusBarStyle setting method

1.0.0 - 2018-06-06T01:31:32

  • Initial release of SupportEmail (renamed from SHSupportEmail)