skip to Main Content

I am trying to launch WhatsApp Business app using Flutter and have written below code:

whatsAppBusiness(phone) {
  print(phone);
  return launchUrl(
    Uri.parse(
      'whatsapp-business://send?phone=$phone',
      // 'https://api.whatsapp.com/$phone', //put your number here
    ),
  );
}

but it is not getting launched.

2

Answers


  1. Interesting question because there’re 2 kinds of WhatsApp. Here what I’ve tried:

    When my phone have only WA Messenger, I tried to type "whatsapp://" in Safari & it open WA Messenger app. But when I install more WA Business, this "whatsapp://" open WA Business.

    I go to WA document: https://faq.whatsapp.com/5913398998672934, it tells us to use deep linking like this: https://wa.me/{phone}?text={text}. I followed it & it open WA Messenger!

    OK so what come to conclusion? If your phone contains 2 WA apps:

    • To open WA Business: "whatsapp://send?phone=$phone"
    • To open WA Messenger: use deep linking (reference above) https://wa.me/{phone}?text={text}
    • To open WA but don’t care what kind of it: just use "whatsapp://send?phone=$phone"

    P/s: Your whatsapp-business:// not working, maybe because it doesn’t exist?!

    P/s 2: Don’t forget to config info.plist & Android manifest as url launcher requires.

    Login or Signup to reply.
  2. No need to specify whatsapp business.

    just open whatsapp.

    if you have both apps installed (whatsapp, whatsapp business), you will be given the choice of which one to open

    so, just open whatsapp, here an example:

    ElevatedButton(
                  onPressed: () {
                    String phone = '123';
                    String infoText = 'blabla';
                    String whatsappUrl =
                        "whatsapp://send?phone=$phone" "&text=${Uri.encodeFull(infoText)}";
                    try {
                      launchUrlString(whatsappUrl);
                    } catch (e) {
                      //handle error properly
                    }
                  },
                  child: const Text('whatsapp'),
                )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search