I am looking for a way to share both an image (a screenshot generated by the app) and text, with a preference to the image. When I try to achieve this, I see it only works for Apple's own Messaging app and maybe a few other apps. But I don't see apps like Snapchat, Tiktok and other famous apps show up in the default share menu that's provided by Apple. For other apps, only the text shows up and the image is ignored. However, when I leave out the text from the UIActivityViewController so it only contains the image to share, all other apps show up and most of them work perfectly with my image. How can I make my code so that, if supported, it shares BOTH the image and the text and in other cases gives preference to the image instead of the text. I still want all the apps (like Snapchat, Tiktok and other social media apps) to show up to share to it because this only happens when only the image is in the UIActivityViewController.
This is the code to make sharing work in my app.
func shareMenu() {
if var top = scene?.view?.window?.rootViewController {
while let presentedViewController = top.presentedViewController {
top = presentedViewController
}
let screenshotImage = getScreenshot(scene: scene!)
let activityVC = UIActivityViewController(activityItems: [screenshotImage , "The text that's need to be shared."], applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = view
top.present(activityVC, animated: true, completion: nil)
}
}