Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joe-scotto/emaillink
A SwiftUI component to make the handling of email links better.
https://github.com/joe-scotto/emaillink
ios swift swift-package-manager swiftui
Last synced: 2 months ago
JSON representation
A SwiftUI component to make the handling of email links better.
- Host: GitHub
- URL: https://github.com/joe-scotto/emaillink
- Owner: joe-scotto
- License: mit
- Created: 2022-07-13T18:46:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-18T15:26:22.000Z (over 1 year ago)
- Last Synced: 2024-11-08T18:03:22.338Z (3 months ago)
- Topics: ios, swift, swift-package-manager, swiftui
- Language: Swift
- Homepage:
- Size: 34.2 KB
- Stars: 23
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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**](#schemes) section for more information.
```xml
LSApplicationQueriesSchemes
googlegmail://
ms-outlook://
readdle-spark://
ymail://
airmail://
```
3. Add the component where you want to use it
```swift
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 LicenseCopyright (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.