Swiftpack.co - vtourraine/ThirdPartyMailer as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by vtourraine.
vtourraine/ThirdPartyMailer 2.0.0
Interact with third-party iOS mail clients, using custom URL schemes.
⭐️ 102
🕓 1 week ago
iOS
.package(url: "https://github.com/vtourraine/ThirdPartyMailer.git", from: "2.0.0")

ThirdPartyMailer

Interact with third-party iOS mail clients, using custom URL schemes.

Platform iOS Swift 5 Build Status Swift Package Manager CocoaPods compatible Carthage Compatible MIT license

Supported mail clients

Client URL Scheme App Store
Sparrow sparrow discontinued
Gmail googlegmail link
Dispatch x-dispatch link
Spark readdle-spark link
Airmail airmail link
Microsoft Outlook ms-outlook link
Yahoo Mail ymail link
Fastmail fastmail link

Unfortunately, not all mail clients offer URL schemes to be supported by ThirdPartyMailer. If you’re aware of another candidate, please let us know.

How to install

Swift Package Manager

In Xcode, click on the “File” menu, “Swift Packages”, “Add Package Dependency…”, then enter the URL for this repo: https://github.com/vtourraine/ThirdPartyMailer.git.

CocoaPods

With CocoaPods, simply add ThirdPartyMailer to your Podfile:

pod 'ThirdPartyMailer'

Or, you can manually import the files from the Sources folder.

How to use

Getting the list of supported clients

let clients = ThirdPartyMailClient.clients

Testing the client availability (i.e. if the app is installed)

⚠️ In order to test the client availability, your app needs to declare the relevant URL scheme in its Info.plist file, by adding a LSApplicationQueriesSchemes array. You can find an example here, or check out the documentation.

if ThirdPartyMailer.isMailClientAvailable(client) {
    // ...
}

Opening the client (with optional message recipient, subject, body, cc, and bcc)

ThirdPartyMailer.openCompose(client, recipient: "friend@mail.com")

ThirdPartyMailer.openCompose(client, recipient: "friend@mail.com", subject: "Hello", body: "Good morning…", cc: "cc@mail.com", bcc: "bcc@mail.com")

:new: Using the system default mail client

If you don’t specify a client, the openCompose(…) function will use .systemDefault, a client defined for the standard mailto: scheme. By default, it will open Apple Mail, but if the user has selected a custom mail client (iOS 14), it will automatically open it instead.

ThirdPartyMailer.openCompose(recipient: "friend@mail.com")

Requirements

ThirdPartyMailer is written in Swift 5.0, requires iOS 10.0 and above, Xcode 10.2 and above.

Credits

ThirdPartyMailer was created by Vincent Tourraine.

License

ThirdPartyMailer is available under the MIT license. See the LICENSE.txt file for more info.

GitHub

link
Stars: 102
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

ThirdPartyMailer 2.0.0
1 week ago
  • Add ThirdPartyMailClient.systemDefault (mailto:)
  • Support cc and bcc parameters
  • Replace deprecated openURL(_) with open(_, options: , completionHandler:)
  • Update ThirdPartyMailClient.composeURL(...) with default parameters values
  • Rename ThirdPartyMailClient clients() to clients
  • Update ThirdPartyMailer functions with completion handler instead of boolean return value
  • Rename ThirdPartyMailer application(_, isMailClientAvailable:) to isMailClientAvailable(_), with default parameters values
  • Rename ThirdPartyMailer application(_, openMailClient:, completionHandler:) to open(_, completionHandler:), with default parameters values
  • Rename ThirdPartyMailer application(_, openMailClient:, recipient:, subject:, body:, completionHandler:) to openCompose(_, recipient:, subject:, body:, cc:, bcc:, completionHandler:), with default parameters values
  • Require iOS 10

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics