Skip to content

Instantly share code, notes, and snippets.

@christianselig
Created May 14, 2020 17:40
Show Gist options
  • Save christianselig/156423398d5b3acba52fb095204b29ea to your computer and use it in GitHub Desktop.
Save christianselig/156423398d5b3acba52fb095204b29ea to your computer and use it in GitHub Desktop.
class TextAndImageActivityItemSource: NSObject, UIActivityItemSource {
let text: String
let image: UIImage
init(text: String, image: UIImage) {
self.text = text
self.image = image
}
func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any {
return image
}
func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivity.ActivityType?) -> Any? {
if activityType?.rawValue == "net.whatsapp.WhatsApp.ShareExtension" {
// Works due to being a single item
return image
} else {
// Does not work, provides empty data
return [text, image]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment