I am trying to open a particular contact chat in whatsapp but not getting any solution. Please help i am totally stuck. I have tried this:
let whatsAppURL: N
Add attributes to the Info.plist
source code file like this:
LSApplicationQueriesSchemes
whatsapp
Use the following function on custom click in your app:
func openWhatsapp(){
let urlWhats = "https://wa.me/numberWithCountryCode"
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 {
Alert(withMessage: "You do not have WhatsApp installed! \nPlease install first.").show(andCloseAfter: 2.0)
}
}
}
}