Skip to content

kartikbhalla12/react-native-truecaller

Repository files navigation

@kartikbhalla/react-native-truecaller

Truecaller Integration with React Native for both Android[SDK v3.0.0] and IOS[SDK v0.1.8]

Installation

npm install @kartikbhalla/react-native-truecaller

Configuration

Android

  • Generate client-id using Truecaller Android Guide

  • Add the following tag to your AndroidManifest.xml file:

    <meta-data 
        android:name="com.truecaller.android.sdk.ClientId"
        android:value="YOUR_CLIENT_ID"
    />
    

iOS

  • Generate AppKey using Truecaller IOS Guide

  • Add the entry truesdk under LSApplicationQueriesSchemes in into your Info.plist file

    <key>LSApplicationQueriesSchemes</key>
    <array>
    <string>truesdk</string>
    </array>
    
  • Add the associated domain provided by Truecaller in Your project -> Capabilities > Associated Domains. The prefix 'applinks:' is needed for universal links to function properly. Note that there is no http:// or https:// prefix when setting up the applinks:

Associated domains

  • Starting with SDK version 0.1.7, It is mandatory to register urlScheme in your project, in the below format: truecallersdk-YOUR_APP_KEY.

URL objects

Usage

  • Install pods to the project

    pod install
    
  • Import the package using

    import { useTruecaller, TRUECALLER_ANDROID_CUSTOMIZATIONS } from '@kartikbhalla/react-native-truecaller';
    
  • Use the truecaller hook

    const { initializeTruecaller, openTruecallerModal, user, isTruecallerSupported } = useTruecaller({
        iosAppKey: 'YOUR_IOS_APP_KEY',
        iosAppLink: 'YOUR_IOS_APP_LINK',
        androidButtonColor: '#FF0000',
        androidButtonStyle: TRUECALLER_ANDROID_CUSTOMIZATIONS.BUTTON_STYLES.ROUND,
        androidButtonText: TRUECALLER_ANDROID_CUSTOMIZATIONS.BUTTON_TEXTS.CONTINUE,
        androidButtonTextColor: '#FFFFFF',
        androidClientId: 'YOUR_ANDROID_CLIENT_ID',
        androidConsentHeading: TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.LOG_IN_TO,
        androidFooterButtonText: TRUECALLER_ANDROID_CUSTOMIZATIONS.FOOTER_BUTTON_TEXTS.SKIP,
    });
    
  • Initialize trucaller using

    useEffect(() => {
        initializeTruecaller();
    }, []);
    
  • You can verify if the truecaller is supported using

    const isSupported = isTruecallerSupported();
    
  • Open truecaller modal using

    openTruecallerModal();
    
  • Once submitted, the data will be available in the user object.

    console.log(user);
    

Customizations

Android supports customizations available in Android Truecaller SDK Customizations. To customize these, you can use the following constants available inside TRUECALLER_ANDROID_CUSTOMIZATIONS

Android Button Texts

TRUECALLER_ANDROID_CUSTOMIZATIONS.BUTTON_TEXTS.CONTINUE
TRUECALLER_ANDROID_CUSTOMIZATIONS.BUTTON_TEXTS.ACCEPT
TRUECALLER_ANDROID_CUSTOMIZATIONS.BUTTON_TEXTS.CONFIRM
TRUECALLER_ANDROID_CUSTOMIZATIONS.BUTTON_TEXTS.PROCEED

Android Button Styles

TRUECALLER_ANDROID_CUSTOMIZATIONS.BUTTON_STYLES.ROUND
TRUECALLER_ANDROID_CUSTOMIZATIONS.BUTTON_STYLES.RECTANGLE

Android Footer Button Texts

TRUECALLER_ANDROID_CUSTOMIZATIONS.FOOTER_BUTTON_TEXTS.SKIP
TRUECALLER_ANDROID_CUSTOMIZATIONS.FOOTER_BUTTON_TEXTS.ANOTHER_MOBILE_NUMBER
TRUECALLER_ANDROID_CUSTOMIZATIONS.FOOTER_BUTTON_TEXTS.ANOTHER_METHOD
TRUECALLER_ANDROID_CUSTOMIZATIONS.FOOTER_BUTTON_TEXTS.MANUALLY
TRUECALLER_ANDROID_CUSTOMIZATIONS.FOOTER_BUTTON_TEXTS.LATER

Android Consent Heading Texts

TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.LOG_IN_TO
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.SIGN_UP_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.SIGN_IN_TO
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.VERIFY_NUMBER_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.REGISTER_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.GET_STARTED_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.PROCEED_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.VERIFY_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.VERIFY_PROFILE_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.VERIFY_YOUR_PROFILE_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.VERIFY_PHONE_NO_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.VERIFY_YOUR_NO_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.CONTINUE_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.COMPLETE_ORDER_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.PLACE_ORDER_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.COMPLETE_BOOKING_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.CHECKOUT_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.MANAGE_DETAILS_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.MANAGE_YOUR_DETAILS_WITH
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.LOGIN_TO_WITH_ONE_TAP
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.SUBSCRIBE_TO
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.GET_UPDATES_FROM
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.CONTINUE_READING_ON
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.GET_NEW_UPDATES_FROM
TRUECALLER_ANDROID_CUSTOMIZATIONS.CONSENT_HEADING_TEXTS.LOGIN_SIGNUP_WITH

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT