Open jtormey opened 4 months ago
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.
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.
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.
I implemented this a while back and can likely reuse much of this code: https://github.com/93software/lynx