I'm trying to create an iOS share extension in swift. When the user is in safari and opens the share extension, I want to be able to grab the URL and use it in my app. I know I can put the code below in the didSelectPost() function in the ShareViewController to get the text that the user enters in the share extension, but how do I get the URL of the web page the user is on when they click the share extension? I'm fairly new to iOS extensions, so any help would be much appreciated.
let shareDefaults = NSUserDefaults(suiteName: "groupName")
shareDefaults?.setObject(self.contentText, forKey: "stringKey")
shareDefaults?.synchronize()
This is how you get the URL:
Or in Swift: