Same issue is only happening to me if we are using Link Preview in UITableView swift.
But for single preview without tableView, it works fine using this code in Swift:
guard let url = URL(string: strLink) else { return }
let linkPreview = LPLinkView()
let provider = LPMetadataProvider()
Task {
let metaData = try await provider.startFetchingMetadata(for: url)
linkPreview.metadata = metaData
//Display your linkPreview
}
For Closures
provider.startFetchingMetadata(for: url) { [weak self] metaData, error in
if let data = metaData, error == nil, let _self = self {
DispatchQueue.main.async {
linkPreview.metadata = data
//Display your linkPreview
}
}
}