NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

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

   

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until October 1st.

Click to save your free spot now

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.