lax icon indicating copy to clipboard operation
lax copied to clipboard

Support unfurling links in messages

Open jtormey opened this issue 1 year ago • 3 comments

I implemented this a while back and can likely reuse much of this code: https://github.com/93software/lynx

jtormey avatar Jul 23 '24 23:07 jtormey

iOS has the Link Presentation framework, which could be used to display link previews.

It provides the LPLinkView, which is a UIKit UIView that could be wrapped with a UIViewRepresentable to include in SwiftUI.

image

carson-katri avatar Jul 25 '24 13:07 carson-katri

That's cool, does this fetch the link every time the view is rendered?

On web, the way I've done this in the past is to have a background process request data for the link, then store those results in the database and render them underneath the message.

jtormey avatar Jul 25 '24 13:07 jtormey

You can cache the LPLinkMetadata however you want in your app. But if you're driving it with server-side data, you can construct the LPLinkMetadata from your own values and still use LPLinkView for the UI.

carson-katri avatar Jul 25 '24 13:07 carson-katri