

Use the first approach as the default and if everything fails, the second approach can fix the problem. You can combine both ideas with the best of all worlds.since the recipient’s number is exposed, you have to handle all the security to cypher the number in the best way you can.you have to implement an HTTP client in order to post the message in an URL.you have to escape the whole message to make it easy to send it in a URL, it is, change all apostrophes, symbols, accents to a friendly HTML code.you need a real valid number to send the message to.You don’t need to have the app installed in the smartphone (although your device’s phone will be retrieved at the moment to send the message).This solution will open the default browser in your Android device to send the message via Web. There’s an API than can also send the message using basic HTTP connections with a modified URL with the phone you want to contact and the message you want to send (sorry, no emojis allowed too). In the snippet above, I just send a Log message when the app is not installed in the device. Second Approach: The user has no WhatsApp installed the message is not text plain or attachments want to be send.You allow to WhatsApp to take care of all the security and user’s privacy and exposed data.You don’t need the actual phone number hardcoded in your snippet.This is the same way it works in any social media apps to share contents.Is like the Share button in all the Social Media that integrates instant messaging to go on certain features. After you tap in the icon, WhatsApp will open allowing you to choose among your contacts who to send this message to. This solution will open a small window that lists all the apps that matches with the app Id “com.whatsapp”. Here’s the snippet in Kotlin: val whatsAppAppId = " com.whatsapp" fun openWhatsAppAndSendMessage(message: String) The WhatsApp appID in the Google Play Store (“com.whatsapp”).Although the solution may be trivial I found a couple of solutions that you might consider given its pros and cons. I have an Android App where, one of the flows ends with the user sending a generated message in my app to another person using WhatsApp. Last week I’ve been thinking on ideas of how to help others at the office (I’ll write soon a better approach of this idea) but then I started to think in ways to send a message using WhatsApp or any other instant messages apps. Interaction between apps is a common thing this days.

Sending messages generated in your app through WhatsApp
