Send WhatsApp Messages using the Android SDK

Learn how to use this Android SDK to Send WhatsApp Messages using the WhatsApp API

Before jumping into using the SDK, let’s follow the below steps to create the project on developers.facebook.com to claim the phone number id.

Step 1: Create a WhatsApp App

Give your app a descriptive name (do not use any Facebook trademarks like WhatsApp or Facebook in the app name) and click the Create App button to create the app.

On the next screen, you will be required to link your WhatsApp app to your Facebook business account. You will also have the option to create a new business account if you don’t have one yet.

Step 2: Add Recipient’s phone number

Your WhatsApp app will provide you with a temporary access token that will be valid for 23 hours. Make a note of this token as we’ll need it in a later step.

Use below Android SDK to Send WhatsApp Messages using the WhatsApp API

Kindly use the following links to use this library:

In settings.gradle (Project)

dependencyResolutionManagement {
repositories {
…….
maven { url ‘https://jitpack.io' }
}
}

And then in the other gradle file(maybe your app gradle or your own module library gradle, but never add in both of them to avoid conflict.)

dependencies {
implementation ‘com.github.myinnos:WhatsApp-SDK:<latest-version>’
}

How to use
— — -
Step 2: implement the App Icon Name Changer method :

Example — MainActivity.kt

WhatsAppInitialization.sendMessage(
“token”, //token
“version”, //ex: v13.0
“phone_number_id”, //ex: 103075932423434
“customer_phone_number”,
“template_name”, //ex: hello_world
“language_code”, //ex: en_US
) { wResult ->
Handler(Looper.getMainLooper()).post {
if (wResult?.getMessage() == null) {
// failed results
} else {
// success results
Log.d(“RESULTS”, wResult.getMessage())
}
}
}

Any Queries? or Feedback, please let me know by opening a new issue

PS: Images in the article are taken from labnol

Let me know your thoughts on Twitter.

--

--

--

Mobile Engineer, UI/UX. I believe in the quote, “Creativity is thinking up new things. Innovation is doing new things.” Happy Coding :)

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The state and future of LoRa Server

Enable Debugging in Twig Templates — Drupal 8

9 Benefits of Migrating Your Business to the Cloud

Get Your Python Flask App Deployed In a Swift

The best courses for voice app and chatbot development

Use This API And Javascript To Get Corn Prices

What Are Foreign Currency Tracker APIs And Why Are They Useful

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Prabhakar Thota

Prabhakar Thota

Mobile Engineer, UI/UX. I believe in the quote, “Creativity is thinking up new things. Innovation is doing new things.” Happy Coding :)

More from Medium

Android Runtime Permissions[Updated with Android 11] — Howtodoandroid

Creating Lists — How to Implement RecyclerView in the MVVM? Use DiffUtils

Integration of Huawei Remote Configuration in Quiz Android app (Kotlin) — Part 3

Remote Upgrade (install) for Android .apk file