i would like to get the url via an action extension in every app, not just safari. For example in twitter.app when you long press a link the share sheets opens and extensions can use the url. If possible i would like to do it without the javascript file.
Currently i am using a js file to get the url in safari and this works, but in other apps like twitter only a black screen appears.
let extensionItem = extensionContext?.inputItems.first as! NSExtensionItem
let itemProvider = extensionItem.attachments?.first as! NSItemProvider
let propertyList = String(kUTTypePropertyList)
if itemProvider.hasItemConformingToTypeIdentifier(propertyList) {
itemProvider.loadItemForTypeIdentifier(propertyList, options: nil, completionHandler: { (item, error) -> Void in
let dictionary = item as! NSDictionary
NSOperationQueue.mainQueue().addOperationWithBlock {
let results = dictionary[NSExtensionJavaScriptPreprocessingResultsKey] as! NSDictionary
let urlString = results["currentUrl"] as? String
self.url = NSURL(string: urlString!)
print(self.url)
}
})
} else {
print("error")
}
I would like to get the url through the share sheet in every app without the need for a javascript file.
thanks in advance