A SwiftUI component to make handling of email links better.

Related tags

Animation EmailLink
Overview

EmailLink

A SwiftUI component to make handling of email links better. Not only will EmailLink use the correct default client, it will also prompt the user to select which to use if they have multiple installed.

Platforms

Tested on iOS 16.0 but should work on iOS and iPadOS 13.0 and up.

Setup

  1. Add the package to your Swift Package Dependencies
  2. Whitelist the URL schemes in your Info.plist. Refer to the Schemes section for more information.
    <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>googlegmail://</string>
        <string>ms-outlook://</string>
        <string>readdle-spark://</string>
        <string>ymail://</string>
        <string>airmail://</string>
    </array>
  3. Add the component where you want to use it
    EmailLink("[email protected]") {
        Text("Contact Us")
    }    

Parameters

Below are the parameters available on EmailLink.

Parameter Type Required Note
to String Yes Where to send the email
subject String No Subject to populate
body String No Email body to populate
color UIColor No Color for ActionSheet buttons
label View Yes View to show as the EmailLink

Schemes

In order for EmailLink to work, you must include LSApplicationQueriesSchemes along with the associated values in your Info.plist. The most common iOS email clients are supported. If an email client is not listed here, it will default to the built-in iOS mailto: scheme which will use the system default app.

Issues

The main reason for this package is to deal with the buggy iOS implementation of the default mail app where sometimes it will not actually try to open. Therefore, it is possible that the mailto: scheme may or may not work depending on if that iOS version is working with the default app setting. This shouldn't be an issue as EmailLink handles most clients however, I wanted to mention it in case this issue arrises.

License

MIT License

Copyright (c) 2022 Joe Scotto

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You might also like...
LottieUI - A library developed to make Lottie easy to implement. It supports iOS and macOS

LottieUI It is a library developed to make Lottie easy to implement. It supports

API to make great custom transitions in one method
API to make great custom transitions in one method

AZTransitions Make your modal transition with custom animation. AZTransitions helps you think about creativity, giving specific API methods. Visual Ex

SwiftUI animated image view that works on iOS and layout just as SwiftUI.Image

SwiftUI.AnimatedImage SwiftUI animated image view that works on iOS and layout just as SwiftUI.Image Screen.Recording.2021-07-31.at.02.18.33.mov Insta

SwiftUI Animation Library. Useful SwiftUI animations including Loading/progress, Looping, On-off, Enter, Exit, Fade, Spin and Background animations that you can directly implement in your next iOS application or project. The library also contains huge examples of spring animations such as Inertial Bounce, Shake, Twirl, Jelly, Jiggle, Rubber Band, Kitchen Sink and Wobble effects. Browse, find and download the animation that fits your needs. SwiftUI-Text-Animation-Library - Text animation library for SwiftUI
SwiftUI-Text-Animation-Library - Text animation library for SwiftUI

⚠️ This repository is under construction. SwiftUI Text Animation Library Make yo

Swiftui-animation-observer - Track SwiftUI animation progress and completion via callbacks
Swiftui-animation-observer - Track SwiftUI animation progress and completion via callbacks

SwiftUI Animation Observer Track SwiftUI animation progress and completion via c

SwiftUI project demonstrating Custom coded confetti animation for checkout page
SwiftUI project demonstrating Custom coded confetti animation for checkout page

Confetti-Checkout SwiftUI project demonstrating Custom coded confetti animation for checkout page NOTE: CAEmitterLayer is not used but all the confett

Fortune spinning wheel library built using SwiftUI, supports dynamic content.
Fortune spinning wheel library built using SwiftUI, supports dynamic content.

Fortune Wheel Fortune spinning wheel 🎡 library built using SwiftUI, supports dynamic content. Preview - Spin Wheel ⚙️ CocoaPods Installation FortuneW

Incognito animation made with SwiftUI
Incognito animation made with SwiftUI

IncognitoSwiftUI Incognito animation made with SwiftUI Incognito Mode / Private Browsing Private browsing is a privacy feature in some web browsers. W

Comments
  • LSApplicationQueriesSchemes check needs to validate individual values.

    LSApplicationQueriesSchemes check needs to validate individual values.

    // Ensure Info.plist includes required schemes
    guard (Bundle.main.infoDictionary?["LSApplicationQueriesSchemes"]) != nil else {
        // Check individual schemes
    
        fatalError("Your Info.plist is missing \"LSApplicationQueriesSchemes\". Please refer to the EmailLink documentation for more details.")
    }
    
    opened by joe-scotto 0
  • mailto: occasionally defaulting

    mailto: occasionally defaulting

    Sometimes mailto: is being called before any of the installed apps are attempted to open. Leading to the default iOS mail app being opened instead of the expected actual default.

    opened by joe-scotto 1
Releases(1.0.3)
Owner
Joe Scotto
Maker of Things.
Joe Scotto
Framework to help you better manage UITableViews

UITableView made simple ?? Main Features ?? Skip the UITableViewDataSource & UITableViewDelegate boilerplate and get right to building your UITableVie

null 84 Feb 4, 2022
A framework and generator for displaying SwiftUI component libraries

Exhibition Exhibition is a framework and generator for displaying a SwiftUI component library. Inspired by Storybook and Showkase Installation Swift P

Malcolm Jarvis 23 Dec 30, 2022
iOS Component for creating a pulsing animation.

PulsingHalo PulsingHalo has been discontinued, and is no longer being maintained. Please check out Pulsator which is the new version of this written w

Shuichi Tsutsumi 1.8k Dec 29, 2022
TRightImageButton is a simple and flexible UI component fully written in Swift.

TRightImageButton is a simple and flexible UI component fully written in Swift. TRightImageButton is developed to help programmers create a button with right image quickly without having to write many lines of codes.

Nguyen Duc Thinh 2 Aug 18, 2022
TTouchAnimatedButton is a simple and flexible animation component fully written in Swift

TTouchAnimatedButton is a simple and flexible animation component fully written in Swift. TTouchAnimatedButton is developed to make user feel button click becomes more vivid and realistic.

Nguyen Duc Thinh 2 Aug 18, 2022
A DSL to make animation easy on iOS with Swift.

This project is highly inspired by JHChainableAnimations, If you project is developed with Objective-C, use JHChainableAnimations instead. With DKChai

Draven 1.9k Dec 9, 2022
Presentation helps you to make tutorials, release notes and animated pages.

Presentation helps you to make tutorials, release notes and animated pages.

HyperRedink 3k Dec 28, 2022
CCMRadarView uses the IBDesignable tools to make an easy customizable radar view with animation

CCMRadarView CCMRadarView is a simple to use view that uses the new IBDesignable and IBInspectable features of XCode6 to easily configure the icon in

Carlos Compean 183 Sep 17, 2022
Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.

Twinkle ✨ Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle. This library creates several CAEmitterLayers and animate

patrick piemonte 600 Nov 24, 2022
Accessbility workshop by hacking with swift. Make every app more usefull for the all the users

Accessibility Accessbility workshop by hacking with swift. Make every app more u

Pavel Surový 0 Dec 26, 2021