How to share image and text on Linkedin or Whassap using UIActivityViewController?

Hi team, using this implementation :

@objc func shareImage(_ base64: String, title: String) {

    if let image = base64.imageFromBase64 {
        DispatchQueue.main.async {
            guard let appDelegate = UIApplication.shared.windows.first?.rootViewController else { return }
        
            let dataToShare = [title , image] as [Any]
            let activityViewController = UIActivityViewController(activityItems: dataToShare, applicationActivities: nil)

            activityViewController.excludedActivityTypes = [UIActivity.ActivityType.airDrop]
            if let popoverController = activityViewController.popoverPresentationController {
                popoverController.sourceRect = CGRect(x: UIScreen.main.bounds.width / 2, y: UIScreen.main.bounds.height / 2, width: 0, height: 0)
                popoverController.sourceView = appDelegate.view
                popoverController.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
            }
            appDelegate.present(activityViewController, animated: true, completion: nil)
        }
    }
}

I only share a text without an image. Should I need to add something on this implementation.

I can confirm this implementation can share text and image on Facebook, Instagram, Telegram.

Thanks in advance.

Answered by klimchuk in 768578022

I don't have an answer on this specific question but my observations of Twitter app indicate that functionality affected by the app you're trying to share text/image with. Sometimes it works, sometimes it's not. It's up to LinkedIn or WhatsUp to fix it.

Accepted Answer

I don't have an answer on this specific question but my observations of Twitter app indicate that functionality affected by the app you're trying to share text/image with. Sometimes it works, sometimes it's not. It's up to LinkedIn or WhatsUp to fix it.

How to share image and text on Linkedin or Whassap using UIActivityViewController?
 
 
Q