I need to create a preview of the url with the thumbnail and some metadata with. How can i get the thumbnail of the url and metadata so that i generate a preview of the url. I have no idea how get thumbnail and metadata.I've searched for this, but could not get anything in iOS(not in objective or swift). I will be thankful for any useful links as well.
You can use a preview i dont know if this is what you are expecting. In this example im downloading the preview of the metadata site. Then I have a UIView and adding in the MAIN THREAD with:
self?.viewContainer.addSubview(linkPreview)
I hope this will help you!
Your friendly Mexican neighbor R.A, Regards
import LinkPresentation
func fetchPreview(urlString: String){
guard let url = URL(string: urlString) else {
return
}
let linkPreview = LPLinkView()
let provider = LPMetadataProvider()
provider.startFetchingMetadata(for: url, completionHandler: {
[weak self] metaData, error in
guard let data = metaData, error == nil else{
return
}
DispatchQueue.main.async {
linkPreview.metadata = data
self?.viewContainer.addSubview(linkPreview)
linkPreview.frame = CGRect(x: 0, y: 0, width: 349, height: 245)
}
})
}
Final result
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With