-1

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..

1 Answers1

1

You can not pass the pdf file via url, it's make nonsense. There are another way you can do is custom the UIActivityViewController. You can refer this tutorial for UIActivityViewController customization: https://nshipster.com/uiactivityviewcontroller/

Minh Văn
  • 51
  • 1
  • 4