• 1
Votes
name
name Punditsdkoslkdosdkoskdo

Swift - Only share image with WhatsApp in ios

I'm implementing sharing in an application and I must be able to share with many applications, including WhatsApp

@objc static func shareItem(viewController: UIViewController, position: CGRect, item: [Any], subject: String) {

    // item = [image, title, content, signature]
    let activityVC = UIActivityViewController(activityItems: item, applicationActivities: nil)
    activityVC.popoverPresentationController?.sourceView = viewController.view
    activityVC.popoverPresentationController?.sourceRect = position
    activityVC.setValue(subject, forKey: "subject")

    viewController.present(activityVC, animated: true, completion: nil)
}

I know that WhatsApp does not allow text and image sharing at the same time, so I would only like to share the image.

The problem is that the function I use to share with WhatsApp is also used to share with all other applications, so I can't just leave the image alone in my table

Is there a way to detect that the user will share with WhatsApp and then only send the image?

Thank you in advance