Getting url image from Share extension

I am trying to get the imageURLios sharing extension for a thumbnail generated in action sheet.

I URLget a fine, but I can’t figure out how to get it imageURL.

This is how I get normal URL,

 if let item = extensionContext?.inputItems.first as? NSExtensionItem {
        if let itemProvider = item.attachments?.first as? NSItemProvider {      
            if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeItem as String) {
                itemProvider.loadItem(forTypeIdentifier: kUTTypeItem as String, options: nil, completionHandler: { (url, error) -> Void in
                    if let shareURL = url as? NSURL {

                        let components = URLComponents(url:shareURL as URL, resolvingAgainstBaseURL: true)
                        if  let host = components?.host { self.shareTitle = host }
                        self.shareURL = shareURL.absoluteString!                            
                        self.POSTShareData(completion: nil)
                    }
                    self.extensionContext?.completeRequest(returningItems: [], completionHandler:nil)
                })
            }
        }
    }

I tried to change typeIdentifierto kUTTypeImageno avail. I have it installed info.plist NSExtensionActivationRuleon TRUEPREDICATEto find out what I can get. I think maybe I should be more explicit in .plist??

I am targeting iOS 9.3

+4
source share
1 answer

The workaround is that you can save this URL link in shared UserDefaults

: - allow defaults = UserDefaults ( : "group.com.common.Notification" )

0

Source: https://habr.com/ru/post/1686288/


All Articles