Open Whatsapp on a particular number in swift

后端 未结 7 751
说谎
说谎 2020-12-30 01:50

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         


        
7条回答
  •  生来不讨喜
    2020-12-30 02:28

    Its possible You can send messages to Specfic user.

    Direct app chat url open

    let urlWhats = "whatsapp://send?phone=+919789384445&abid=12354&text=Hello"
        if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed) {
            if let whatsappURL = URL(string: urlString) {
                if UIApplication.shared.canOpenURL(whatsappURL!) {
                    UIApplication.shared.openURL(whatsappURL!)
                } else {
                    print("Install Whatsapp")
                }
            }
        }
    

    Note:Country code (Ex:+91) is mandatory to open mobile number Chat

    WebUrl Link open Chat

     let whatsappURL = URL(string: "https://api.whatsapp.com/send?phone=9512347895&text=Invitation")
        if UIApplication.shared.canOpenURL(whatsappURL) {
            UIApplication.shared.open(whatsappURL, options: [:], completionHandler: nil)
        }
    

    Check below link,

    https://www.whatsapp.com/faq/en/general/26000030

    Note: Add url scheme in info.plist

    LSApplicationQueriesSchemes
     
        whatsapp
     
    

提交回复
热议问题