i need to use Whatsapp share picture in my Swift app utilizing Xcode, the picture will likely be downloaded from url , its working tremendous however the issue is that when i click on on Whatsapp share button it would not open Whatsapp straight however open occasion the place i can see all apps to share ,,, look this picture
i need when person click on on whatsapp it ought to open simply whatsapp straight…
that is my code in button click on
let urlWhats = "whatsapp://app"
if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters:CharacterSet.urlQueryAllowed) {
if let whatsappURL = URL(string: urlString) {
if UIApplication.shared.canOpenURL(whatsappURL as URL) {
// Set your picture's URL into right here
let url = URL(string: "https://www.punjabidharti.com/wp-content/uploads/2022/11/1662625125251-600x600.jpg")!
knowledge(from: url) { knowledge, response, error in
guard let knowledge = knowledge, error == nil else { return }
DispatchQueue.predominant.async() { [self] in
let picture = UIImage(knowledge: knowledge)
if let imageData = picture?.jpegData(compressionQuality: 1.0) {
let tempFile = URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent("Paperwork/whatsAppTmp.wai")
do {
attempt imageData.write(to: tempFile, choices: .atomic)
self.documentInteractionController = UIDocumentInteractionController(url: tempFile)
self.documentInteractionController.uti = "web.whatsapp.picture"
self.documentInteractionController.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)
} catch {
print(error)
}
}
}
}
} else {
self.showToast(message: "Whatsapp Not Put in")
}
}
}