Skip to content

Instantly share code, notes, and snippets.

@ryanisnhp
Last active February 4, 2020 03:06
Show Gist options
  • Save ryanisnhp/59db39d4c547e499e70b448b40b7dc50 to your computer and use it in GitHub Desktop.
Save ryanisnhp/59db39d4c547e499e70b448b40b7dc50 to your computer and use it in GitHub Desktop.
class LinkPresentationItemSource: NSObject, UIActivityItemSource {
var linkMetaData = LPLinkMetadata()
//Prepare data to share
func activityViewControllerLinkMetadata(_ activityViewController: UIActivityViewController) -> LPLinkMetadata? {
return linkMetaData
}
//Placeholder for real data, we don't care in this example so just return a simple string
func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any {
return "Placeholder"
}
/// Return the data will be shared
/// - Parameters:
/// - activityType: Ex: mail, message, airdrop, etc..
func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -> Any? {
return linkMetaData.originalURL
}
init(metaData: LPLinkMetadata) {
self.linkMetaData = metaData
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment