Geek Culture
Published in

Geek Culture

Integrating Truecaller SDK in React Native

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

npm install react-native-truecaller-sdk — save

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.

npm link react-native-truecaller-sdk

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

NOTE: Different app builds ( debug / release ) have different SHA1 fingerprints and hence would have different & unique app keys, as a single app key corresponds to a particular combination of package name and SHA-1. You need to manage your debug / release builds by creating separate keys.

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.

<meta-data android:name="com.truecaller.android.sdk.PartnerKey" android:value="@string/truecaller_appkey"/>

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.

<string name="truecaller_appkey">1234567abcdef</string>

4. Complete Class Code

Refer to the following class for complete code for truecaller implementation

--

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

How we stay up to date with our dependencies

Pitfalls in Android WebView Implementation

Six Months Android Development Industrial Training: Benefits And The Future Scope

Create Google Pay (Tez) like scratch card

Compile-Time Dependency Injection with Dagger 2

Unit Testing in MVVM+Kotlin+DataBinding

How to Create a RecyclerView Adapter

Jetpack Compose Alpha

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
Aaleen Mirza

Aaleen Mirza

Life-long learner | Enthusiastic | Software Developer

More from Medium

How to create a native library to React Native

How to reuse or adapt React components in React Native using WebView on Android?

Benchmarking cryptography in React Native and iOS

Full Screen React Native Android