I am using below code to send a text to a new WhatsApp number using a WhatsApp Url scheme instead of UIActivityViewController.
let urlWhats = "whatsapp://send?phone=+9197******2&text=Hi Hello"
if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters:
CharacterSet.urlQueryAllowed){
if let whatsappURL = URL(string: urlString) {
if UIApplication.shared.canOpenURL(whatsappURL){
if #available(iOS 10.0, *) {
UIApplication.shared.open(whatsappURL, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(whatsappURL)
}
} else {
print("Install Whatsapp")
}
My current requirement is to share a Pdf file to a new WhatsApp number using WhatsApp Url scheme. Can anyone help me with this..