I'm trying to implement share shortcutItem (my implementation):
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if shortcutItem.type == "share"{
self.shareItem()
}
}
func shareItem() {
let visitedlink = "http://google.com"
let myWebsite = NSURL(string: visitedlink)
let img: UIImage = UIImage(named:"Logo")!
guard let url = myWebsite else {
print("nothing found")
return
}
let shareItems:Array = [img,url]
let activityViewController:UIActivityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)
activityViewController.excludedActivityTypes = [UIActivityType.print, UIActivityType.postToWeibo, UIActivityType.copyToPasteboard, UIActivityType.addToReadingList, UIActivityType.postToVimeo, UIActivityType.message, UIActivityType.mail]
self.present(activityViewController, animated: true, completion: nil)
}
But on this line:
self.present(activityViewController, animated: true, completion: nil)
I'm getting this error:
Value of type AppDelegate has no member of present
Any of you knows why I'm getting this error? or work around this?
I'll really appreciate your help.
Try this,