Open WhatsApp chatbox from React-native

Hi Guys, In this article, we are going to learn about How to open WhatsApp chatbox from React-native, Many time developers want to give some feedback, complaint token, from the client for that client can send an email and another way is to provide WhatsApp number for some queries, for this we are using Linking components from React-native core libraries, which allows you to open WhatsApp chatbox for particular number with a text message, so let’s start with an example

Open WhatsApp chatbox from React-nativeOpen WhatsApp chatbox from React-native

1. Create a new project

2. Import the following components

3. Open WhatsApp from React-native App

As you see in the above code, I have created a URL with the text message and telephone number and pass this URL in Linking.openURL(url) this call will return response success or catch the error

4. Full source code

In below code, I have added to TextInput component one for Message and another for Number, define these two var in the constructor state and call method to open WhatsApp chatbox also I have added validation on button click ti check whether message and number is not null, it will throw an error so validation is important in this situation

5. Output

Thank you 🙂Open WhatsApp chatbox from React-native

Thank you 🙂

Leave a Reply

Your email address will not be published.