Truecaller SDK
  • Hello!
  • Why Truecaller SDK
  • Getting Started
  • ANDROID
    • 🆕OAuth SDK 3.0
      • Implementing user flow for your App
      • Scenarios for all user verifications : Truecaller and Non Truecaller Users
      • Integration Steps
        • Generating Client ID
        • Setup
        • Implementing Callbacks
        • Initialisation
        • Setting up OAuth parameters
        • Invocation
        • Customisation
        • Clearing SDK Instance
        • Handling Error Scenarios
        • Integrating with your Backend
          • Fetching User Token
          • Fetching User Profile
        • Non Truecaller User Verification
          • Completing Verification
          • TrueException
          • Server Side Validation
      • Instrumentation
      • Getting Release Ready
        • Testing your verification flow
          • Non-Truecaller user verification flow
          • Truecaller user verification flow
          • Test Setup
        • Google play store app permission declaration form
        • Moving to Production
    • SDK v2.8.0
      • Implementing user flow for your app
      • Scenarios for all user verifications : Truecaller and Non Truecaller Users
      • Generating App Key
      • Integrating with your App
        • Setup
        • App Key Configuration
        • Initialisation
        • Customisation
        • Implement Callbacks
        • Clearing SDK instance
        • Handling Error Scenarios
        • Verifying non Truecaller users
          • TrueException
          • Completing Verification
        • Advanced Steps
      • Server Side Response Validation
        • For Truecaller users verification flow
        • For Non-Truecaller users verification flow
      • Instrumentation
      • Getting Release Ready
        • Testing your verification flow
          • Truecaller user verification flow
          • Non-Truecaller User Verification Flow
          • Test Setup
        • Google Play App Signing
        • Google Play Store app permissions declaration
        • Google Play Policy Change for Device Identifiers
      • Changelog
  • MOBILE WEBSITES
    • Implementing user flow for your Mobile Website
    • Generating App Key
    • Integrating with your mobile website
      • Initialisation
      • Invoking verification
      • Fetch User Profile
      • Completing User Verification
      • Handling Error Scenarios
    • Getting Release Ready
      • Instrumentation
      • Testing your verification flow
  • IOS
    • Generating App Key
    • Integrating with your iOS App
      • Setup
      • Configuration
      • Usage
        • Swift
        • Objective-C
      • Verifying Non-Truecaller app users
        • Completing Verification
      • Handling Error Scenarios
        • Safari Redirection
    • Server Side Response Validation
  • SHOPIFY APP
    • Generating App Key
    • App Configuration
    • Deactivating App Block
  • FAQs
    • General
    • Developer Account
    • Android App SDK
    • Android OAuth SDK
    • Mobile Web SDK
    • Number Verification Plugin
  • PRODUCT UPDATES
    • App Review Process
    • Introducing dark theme
Powered by GitBook
On this page

Was this helpful?

  1. ANDROID
  2. OAuth SDK 3.0
  3. Integration Steps

Implementing Callbacks

  1. In your Activity/Fragment where you want to integrate the Truecaller OAuth flow, either make the component implement the interface TcOAuthCallback or create an instance of it which you would require to initialize TcSdkOptions in the next step.

The interface has 2 functions which need to be overridden -

private val tcOAuthCallback: TcOAuthCallback = object : TcOAuthCallback {
    override fun onSuccess(tcOAuthData: TcOAuthData) {
        ..
    }

    override fun onFailure(tcOAuthError: TcOAuthError) {
        ..
    }
}
  • onFailure() method will be called in case of an error. You would get the error details like the error code and error message through tcOAuthError returned with this method.

  • onSuccess() method will be called when the user gives consent to authorize your app by tapping on the primary button on the Truecaller’s consent screen, and subsequently, an authorization code will be successfully generated and received. This method would return tcOAuthData which contains information like :

    • authorizationCode - which you can utilize to fetch the user’s access token

    • scopesGranted - list of scopes granted by the user

    • state - state parameter returned by the authorisation server. If the state set by your application is the same as the state returned by the authorisation server, it’s safe to proceed further. If state parameters are different, someone else has initiated the request and it could be a case of request forgery.

  1. Override the onActivityResult() method of the component used in step 1 and call the onActivityResultObtained() method if the requestCode matches to TcSdk.SHARE_PROFILE_REQUEST_CODE.

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == TcSdk.SHARE_PROFILE_REQUEST_CODE) {
             TcSdk.getInstance().onActivityResultObtained(this, requestCode, resultCode, data)
        }
}

PreviousSetupNextInitialisation

Last updated 1 year ago

Was this helpful?

🆕