Initialisation

  1. Create a TcSdkOptions object by using the tcOAuthCallback from the previous step and provide the context. Supply the appropriate customization settings to the relevant methods of TcSdkOptions and use the instance of tcSdkOptions to initialize the TcSdk in the next step.

val tcSdkOptions = TcSdkOptions.Builder(this, tcOAuthCallback)
.buttonColor(Color.parseColor("<<VALID_COLOR_HEX_CODE>>"))
          .buttonTextColor(Color.parseColor("<<VALID_COLOR_HEX_CODE>>"))
            .loginTextPrefix(TcSdkOptions.LOGIN_TEXT_PREFIX_TO_GET_STARTED)
            .ctaText(TcSdkOptions.CTA_TEXT_CONTINUE)
            .buttonShapeOptions(TcSdkOptions.BUTTON_SHAPE_ROUNDED)
            .footerType(TcSdkOptions.FOOTER_TYPE_SKIP)
            .consentTitleOption(TcSdkOptions.SDK_CONSENT_TITLE_LOG_IN)
.build()

In case you do not wish to provide any customization settings and fall back to the default SDK settings, you may simply call -

val tcSdkOptions = TcSdkOptions.Builder(this, tcOAuthCallback).build()
  1. Initialize TcSdk using the tcSdkOptions from the previous step :

TcSdk.init(tcSdkOptions)

Note: Truecaller OAuth SDK needs to be initialized only once in the component and the same instance can be accessed without the need to initialize it again, via TcSdk.getInstance()

Ideally, you should call the init() method when the component is getting created/initialized to avoid calling it multiple times.

  1. Once the SDK is initialized, check whether the OAuth functionality is usable or not by calling :

val isUsable = TcSdk.getInstance().isOAuthFlowUsable

If isUsable is True, you can proceed with further steps, otherwise, you’d have to fall back to some other mechanism ( your fallback verification flow ). Calling other SDK methods when isUsable is False would result in an exception, so please ensure to call this soon after initializing the SDK, and proceed to further steps only if this method returns True.

Last updated