UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

ShareLink

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

ShareLink(
    item: tappableLink,
    subject: Text(LocalizedAppConstants.shareAppLinkSubject),
    message: Text(LocalizedAppConstants.shareingAppLinkBody),
    preview: SharePreview(
        card.appData.trackName!,
        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

2      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.