The issue I have with the Link Preview API is that fetching the metadata via the LPMetadataProvider must be called on the main thread - and even though it returns on a background thread, it instantiates a WKWebView to get the metadata, and that is done on the main thread. So, if loading a UIStackView with MANY link previews that have not been cached, the process for the first load will take a very long time and will also block the main thread. Is there any way to get LPLinkMetadata in advance? I don’t think that it can be fetched when the app itself is in the background because we need the main thread. I am sure I am probably just misunderstanding some basic concept here, but what would your strategy be for loading the metadata via LPMetadataProvider for MANY links in advance of actually showing the view with the LPLinkViews?
I completely agree that it’s a bit ridiculous that you can’t do that, and the fact that it’s a main-thread object, AND the fact that it’s a one-shot object. These “issues” (is it a bug or a feature) seem to suggest that Apple really wants you to create link previews one-by-one instead of in bulk, so I don’t think there’s a good way of doing this at the moment. Let’s hope they have come to their senses by WWDC 2020 and give us some improvements!
1 Like
So basically, at this point, there is no strategy that you can think of that would work? I am not very advanced in my understanding of this and I was hoping that you might be able to suggest a way to approach this. I am very concerned that Apple will NOT address this in the next iOS. I did file a bug report, but all of the bug reports I have ever filed have basically gone ignored.
Personally, I have not found a good way to address this issue, no.
1 Like
Is there a way to have the link open up in SafariViewController modally after tapping the linkView instead of leaving the app and opening Safari? I’ve looked but haven’t found anything yet.
I know it’s early, but at first glance I don’t see any improvements to the Link Preview API. Am I wrong?
@leamars Can you please help with this when you get a chance? Thank you - much appreciated! :]
Hi @leamars ,nice tutorial. Is there any way to get og:description or og:title information in metadata? If I want to customize my rich links preview, I need those information. Any advise is appreciated. Thanks!