I am using webview
for my Swift app and I have \"Share on WhatsApp\" button on my website which works fine on a browser. But on iPhone app, when I click on the butt
For this you should use URL schemes.
let message = "Message"
let urlWhats = "whatsapp://send?text=\(message)"
if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed) {
if let whatsappURL = NSURL(string: urlString) {
if UIApplication.shared.canOpenURL(whatsappURL as URL) {
UIApplication.shared.open(whatsappURL as URL, options: [:], completionHandler: { (Bool) in
})
} else {
// Handle a problem
}
}
}