denickman
denickman

Reputation: 29

iOS Share Extension with Social Networks

Please help me with my issue. Here is the thing. I've added share extension in my app and want to get (share) content from Intagram, Facebook, Twitter to my app using this Share Extension. I use NSExtensionItem and NSItemProvider to get info or data in SLComposeServiceViewController, but all I can get is only link ("public.url") to some post in social networks. My question - How to get more data such as (images, thumbnails, tags etc.).

       if let item = extensionContext?.inputItems.first as? NSExtensionItem,
                let itemProvider = item.attachments?.first as? NSItemProvider,
                itemProvider.hasItemConformingToTypeIdentifier("public.url") {
                itemProvider.loadItem(forTypeIdentifier: "public.url", options: nil) { (url, error) in
                    if let shareURL = url as? URL {
                        // do what you want to do with shareURL
                        print(shareURL)
                        self.shareURL = shareURL
                    }
                }
            }

Upvotes: 1

Views: 218

Answers (0)

Related Questions