Hi All,
I'm working on a custom bookmarking/website diary app which will allow manual input of URLs, but for which I'd like to be able to allow users to do a share action from Safari in order to invoke the app.
I've deployed my first share extension, and in my 'didSelectPost' function, I'm trying to examine the info that comes in, and I'm able to see everything but the comments typed into the share form.
Here's the code I'm using:
override func didSelectPost() {
for item in self.extensionContext!.inputItems {
if let item = item as? NSExtensionItem {
if let x = item.attributedContentText {
NSLog("x = \(x)")
}
let attachments = item.attachments!
NSLog("Item: \(item)")
let provider = attachments.first!
NSLog("PROVIDER \(provider)")
if provider.hasItemConformingToTypeIdentifier("public.url"){
provider.loadItem(forTypeIdentifier: "public.url", options: nil, completionHandler: { (attachment, error) in
if let url = attachment as? URL{
let link = try! String(contentsOf: url, encoding: .utf8)
NSLog("URL: \(url)") // GOT MY URL!
NSLog("link: \(link)") // GOT THE CONTENTS OF THE URL
}
})
}
}
}
self.extensionContext!.completeRequest(returningItems: [], completionHandler: nil)
}
My question is, where do I look to see what the user typed in the share sheet? Every tutorial I've found on this seems to go into great detail on how to share an image, but I seem to be missing the piece about grabbing the user-generated content.