Integrating Truecaller SDK with OTP in Android app

659 views Asked by At

I have been working on a demo app in which I am trying to integrate the Truecaller SDK. I have been successful in adding the part in which the authentication is done using the Truecaller app already installed on the device. But I am not getting how to do the part in which we are supposed to generate the OTP using the Truecaller SDK without installing Truecaller app on the device.

1

There are 1 answers

0
Sagar Balyan On

Initialise Trucaller Scope

    TruecallerSdkScope trueScope = new TruecallerSdkScope.Builder(this, sdkCallback)
            .consentMode(TruecallerSdkScope.CONSENT_MODE_BOTTOMSHEET)
            .buttonColor(Color.parseColor("#ffffff"))
            .buttonTextColor(Color.parseColor("#000000"))
            .loginTextPrefix(TruecallerSdkScope.LOGIN_TEXT_PREFIX_TO_GET_STARTED)
            .loginTextSuffix(TruecallerSdkScope.LOGIN_TEXT_SUFFIX_PLEASE_VERIFY_MOBILE_NO)
            .ctaTextPrefix(TruecallerSdkScope.CTA_TEXT_PREFIX_USE)
            .buttonShapeOptions(TruecallerSdkScope.BUTTON_SHAPE_ROUNDED)
            .privacyPolicyUrl("<<YOUR_PRIVACY_POLICY_LINK>>")
            .termsOfServiceUrl("<<YOUR_PRIVACY_POLICY_LINK>>")
            .footerType(TruecallerSdkScope.FOOTER_TYPE_NONE)
            .consentTitleOption(TruecallerSdkScope.SDK_CONSENT_TITLE_LOG_IN)
            .sdkOptions(TruecallerSdkScope.SDK_OPTION_WITHOUT_OTP)
            .build();

    TruecallerSDK.init(trueScope);

And get the truecaller instance

        TruecallerSDK.getInstance().getUserProfile(this);

Just use these 2 methods, and you will be able to see a Truecaller popup.

NOTE: The user should have the app trucaller INSTALLED and SIGNED IN THE TRUECALLER APP.