I'm trying to share a simple .txt file to WhatsApp using UIDocumentInteractionController on iOS.
I found this FAQ of WhatsApp explaining the Custom URL Scheme for WhatsApp, but it is not explaining how to share another document to WhatsApp. This should be possible with a WhatsApp update released about 2 months ago.
I also found this answer, but it does not work for other document types. Can anyone help me?
My code, that does not work, because the URL Scheme is wrong:
let urlWhats = "whatsapp://app"
if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed) {
if let whatsappURL = URL(string: urlString) {
if UIApplication.shared.canOpenURL(whatsappURL) {
activityVc = UIDocumentInteractionController(url: URL(fileURLWithPath: txtPath))
activityVc.uti = "net.whatsapp.document"
activityVc.presentOptionsMenu(from: CGRect.zero, in: self.view, animated: true)
}
}