Swiftpack.co - edonv/SwiftUIMessage as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by edonv.
edonv/SwiftUIMessage 0.0.4
SwiftUI wrapper of MessageUI framework.
⭐️ 7
🕓 3 weeks ago
iOS macCatalyst
.package(url: "https://github.com/edonv/SwiftUIMessage.git", from: "0.0.4")

SwiftUIMessage

SwiftUI wrapper of MessageUI.

Documentation

Documentation for SwiftUIMessage is hosted on Swift Package Index.

Usage Notes

Always be sure to call MailComposeView.canSendMail() and MessageComposeView.canSendText() in-line to confirm that you can actually use them on that device. And graphical glitches may occur if you don't include the .ignoresSafeArea() view modifier.

It's generally best to use them in a .sheet() modifier, but the code below is just for the sake of example.

Examples

MailComposeView

// This will return false if the device cannot use Apple Mail.
if MailComposeView.canSendMail() {
    MailComposeView(
        .init(subject: "Subject",
              toRecipients: [
                  "[email protected]"
              ],
              ccRecipients: nil,
              bccRecipients: nil,
              body: "This is an example email body.",
              bodyIsHTML: false,
              preferredSendingEmailAddress: nil)
    )
    .ignoresSafeArea()
} else {
    // Here you can tell the user the issue, or maybe launch the URL scheme to open the default mail app (which wouldn't be Apple Mail).
    Text("Mail cannot be sent from your device.")
}

MessageComposeView

if MessageComposeView.canSendText() {
    MessageComposeView(
        .init(recipients: [
                  "111-111-1111",
                  "+1-111-111-1112"
              ],
              subject: "This is an MMS subject line, but it won't be inlcuded if the device doesn't have them enabled.",
              body: "This is an SMS text body.")
    )
    .ignoresSafeArea()
} else {
    // Here you can tell the user the issue.
    Text("Text messages cannot be sent from your device.")
}

GitHub

link
Stars: 7
Last commit: 4 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

v0.0.3
43 weeks ago

Full Changelog: https://github.com/edonv/SwiftUIMessage/compare/0.0.2...0.0.3

Missed making MailComposeView.canSendMail() static function public. This was missed because it doesn't cause any errors when building internally. Thanks to #1 for finding this problem.

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