Integrating Truecaller SDK in React Native

Aaleen Mirza
Mar 9 · 3 min read
Photo by Lindsey LaMont on Unsplash

Recently I’ve been experimenting with Truecaller SDK in React Native. React-native-truecaller-sdk can be used as an alternate method of authenticating users for login/signup. However, it can be difficult to configure the app correctly if you’re new. I am going to guide you through setting up a simple truecaller based authentication in React Native.
(Note: The module is currently supported for Android only)

1. Install & link package

Enter the following command in your project directory

If you are running RN version > 0.60 you can skip the next command as React Native links the libraries itself in the latest versions.

2. Create Application on Truecaller dashboard

Now visit https://developer.truecaller.com/login and create account (if you have not yet created one) and login to truecaller dashboard. Create an app on this dashboard which will be used by truecaller to identify your application.
The following information will be required to create an app.

The goal is to generate an app key [ partner key ] from Truecaller developer account by adding your app name, package name and your app’s SHA-1 key.
You can get your app’s SHA-1 key for different app builds configs (debug/release) by following 3 simple steps:

- Open your project in android studio
- Click on gradle menu on the right side and expand it
- Click on android and then signing report

Fill in the App name, package name and your correct ( as per build config) SHA-1 key and hit ‘Create App’. You will be navigated into the following screen, copy the App Key.

3. App side Setup and Configuration

Open your AndroidManifest.xml file and add the following meta-data element to the application tag.

Now open your strings.xml file and add a new string tag with the name “truecaller_appkey” and value as your “appKey” the one you copied from the truecaller dashboard.

4. Complete Class Code

Refer to the following class for complete code for truecaller implementation

Geek Culture

Proud to geek out. Follow to join our +1M monthly readers.