I have a share extension that is looking for attachments from NSItemProvider, which I'm using to grab the url (e.g. of any website that a user visits on Safari) once the user taps on my app's share extension's button.
As I'm cycling through the attachments I'm looking for public.url, kUTTypeURL, kUTTypeText and kUTTypeData. This works well for normal websites, which usually returns a public.url attachment. However when somebody visits a url that displays a PDF (e.g. a url like this one), then NSItemProvider will only find the attachment type of kUTTypeData. This is my snippet for that:
else if provider.hasItemConformingToTypeIdentifier(kUTTypeData as String) {
provider.loadItem(forTypeIdentifier: kUTTypeData as String, options: nil) { (text, err) in
print("Found kUTTypeData, text: ", text)
}
}
The text printed is something like this:
file:///Users/username/Library/Developer/CoreSimulator/Devices/7558EE15-EA8E-496C-9CC5-B397SAB36039/data/Containers/Data/Application/3465F991-39E1-4330-93C6-2A1A43AFAD81/tmp/QuickLookContent-GLuwMHlh/dummy.pdf
Is there a way to grab the actual url instead?