Home > Enterprise >  How to send message on specific number (Restaurant number - For food ordering) on whatsapp from my f
How to send message on specific number (Restaurant number - For food ordering) on whatsapp from my f

Time:11-01

launchWhatsapp(String mobileNumber,BuildContext context) async {
  var whatsapp = mobileNumber;
  var whatsappAndroid =Uri.parse("whatsapp://send?phone=$whatsapp&text=hello");
  if (await canLaunchUrl(whatsappAndroid)) {
    await launchUrl(whatsappAndroid);
  } else {
    ScaffoldMessenger.of(context).showSnackBar(
      const SnackBar(
        content: Text("WhatsApp is not installed on the device"),
      ),
    );
  }
}

Here, I have used url_launcher plugin,

https://pub.dev/packages/url_launcher

But the mobile number is fixed for all time, mobileNumber = "9876543211"

Now, I want to redirect on whatsapp and open chat on this number for food ordering. so everytime number will be same.

By launchWhatsapp method it redirect me on whatsapp but it shows me that, this number is not registered or saved in your contacts. How do I open chat screen on whatsapp from any device from my flutter app.

CodePudding user response:

Just put a country code as prefix of your mobile number it will work.

CodePudding user response:

You have to give it the full correct number containing the country code

  • Related