I'm using a LPMetadataProvider
to get metadata for URLs.
If I do this
if itemProvider.hasItemConformingToTypeIdentifier(UTType.image.identifier) {
let item = try? await itemProvider.loadItem(forTypeIdentifier: UTType.image.identifier)
// continue with code to convert data to UIImage...
}
That seems to fail quite often, even on larger sites like Amazon where users will expect to see an icon.
I've noticed it's because sometimes the type is dyn.agq80w5pbq7ww88brrfv085u
I'm assuming this is because something about the website response or the image data does not let the system determine if it is actually an image.
If I just do this
let type: String = "dyn.agq80w5pbq7ww88brrfv085u"
if itemProvider.hasItemConformingToTypeIdentifier(type) {
let item = try? await itemProvider.loadItem(forTypeIdentifier: type)
// continue with code to convert data to UIImage...
}
Then I get the icon, so it is there and it is an image. The problem is, does this dynamic type cover everything? Should I even be doing that?
Does anyone know precisely what causes this and are there recommendations on better ways to handle it?
I know LPLinkView appears to do something to load these 'non-image' icons so I am assuming there are way.
My assumption is that it would be safe to look at the results of itemProvider.registeredTypeIdentifiers()
and if it has something use that as the type rather than coming up with a hardcoded list of types to check for.