TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>


Forums > SwiftUI

Hello all,

I am trying to create a hyperlink in SwiftUI using ShareLink. I know that the item you provide to ShareLink must conform to Transferable and that AttributedString conforms to that protocol. However, when I create my attrbuted string I get the hyperlink just fine when sharing via email, but if I share via text message it just shows the words with no hyperlink. I know other apps do this just fine in Text messages, like my 1Password does.

Here is my code:

var tappableLink: AttributedString {
    let markDownLink = try! AttributedString(markdown: "[Download \(card.appData.trackName ?? "Unknown App Name")](\(card.appData.trackViewURL!))")
    return markDownLink

Heres where I use it with ShareLink

    item: tappableLink,
    subject: Text(LocalizedAppConstants.shareAppLinkSubject),
    message: Text(LocalizedAppConstants.shareingAppLinkBody),
    preview: SharePreview(
        image: SFImage.shareApp.image
    label: {
        Label("Share App Link", systemImage: "square.and.arrow.up")

Can anyone help me with getting a hyperlink that says Download <INSERT APP NAME> so that in text or email it works the same. I cannot seem to find out why the above is not working in text message.

Thanks, Taz


Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.