What is the max char limit for the `text` parameter in Whatsapp send text URLs (mobile and web)?

Viewed 2016

How long can I make a whatsapp message when I'm sending it using the whatsapp://send?text= and https://api.whatsapp.com/send?text= URLs?

I know that the general URL size limit is 2048 characters, but does it also apply in this case?
Or is it lower/higher?

3 Answers

Edit: I played with this more and came to know a few more things. Below mentioned limit is probably limit of the windows command line argument system. This limit isn't applicable for web based whatsapp and only applicable for desktop app.

Original: For https://api.whatsapp.com thing there's a hard limit of 2057 characters for the whole URL meaning counting from https...

I checked it myself in Google Chrome. And if you are using non-ASCII characters then limit will be much less.

A text message can be a max of 4096 characters long. Source: WhatsApp API

There is not Char limit I have tried with 11865 Characters.

The complete code is below. Swift 5

Please follow the below steps for sharing on WhatsApp through URL Schemes

  1. Add this code in your app "info.plist"

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>whatsapp</string>
</array>

enter image description here

  1. For sharing text and URL

Code

    @IBAction func whatsappShareText(_ sender: AnyObject) {

    
        let message = "First Whatsapp Share & https://www.google.co.in"
        var queryCharSet = NSCharacterSet.urlQueryAllowed
        
        // if your text message contains special characters like **+ and &** then add this line
        queryCharSet.remove(charactersIn: "+&")
        
        if let escapedString = message.addingPercentEncoding(withAllowedCharacters: queryCharSet) {
            if let whatsappURL = URL(string: "whatsapp://send?text=\(escapedString)") {
                if UIApplication.shared.canOpenURL(whatsappURL) {
                    UIApplication.shared.open(whatsappURL, options: [: ], completionHandler: nil)
                } else {
                    debugPrint("please install WhatsApp")
                }
            }
        }
    }

Happy Coding!

Related