Verifying Non-Truecaller app users

This section defines the steps that can be used to trigger verification of non Truecaller app users which will be powered via Truecaller's SMS based OTP ( Currently available only for India )

On the Mobile number entry screen set the below delegates :

Swift:

TCTrueSDK.sharedManager().delegate = self TCTrueSDK.sharedManager().viewDelegate = self

Objective C:

[TCTrueSDK sharedManager].delegate = self; [TCTrueSDK sharedManager].viewDelegate = self;

viewDelegate needs to be set on the mobile number entry screen i.e. OTP flow (not required for Truecaller one tap flow for Truecaller users verification).

Initiate the verification for the user by calling the following method:

Swift:

TCTrueSDK.sharedManager().requestVerification(forPhone: <#PHONE_NUMBER_STRING>,countryCode: <#DEFAULT_COUNTRY_CODE>)

Objective C: [[TCTrueSDK sharedManager] requestVerificationForPhone:<#PHONE_NUMBER_STRING> countryCode:<#DEFAULT_COUNTRY_CODE>];

  • the first parameter (PHONE_NUMBER_STRING) is the 10-digit mobile number

  • the second parameter is the country code (DEFAULT_COUNTRY_CODE) of the mobile number for which the verification needs to be triggered(“IN” for India)

Once you initiate the verification using the above requestVerification() method, the below delegate method will be called along with the verification state.

Swift: func verificationStatusChanged(to verificationState: TCVerificationState)

Objective C: (void)verificationStatusChangedTo:(TCVerificationState)verificationState;

verificationStatusChanged() delegate method is called under any of the following scenarios :

  • When OTP is successfully triggered for the input mobile number. In this case, you will get the verificationState as TCVerificationState.otpInitiated

  • When the verification is successful for a particular number. In this case, you will get the verificationState as TCVerificationState.verificationComplete

  • When the user is already verified on that particular device. In this case, you will get the verificationState as TCVerificationState.verifiedBefore

Possible Verification states (TCVerificationState) :

State

Description

TCVerificationStateOTPInitiated

Returned when OTP is successfully initiated by Truecaller

TCVerificationStateOTPReceived

Returned when OTP is successfully registered by the partner to Truecaller.

TCVerificationStateVerificationComplete

OTP verification successful at Truecaller

TCVerificationStateVerifiedBefore

The user has already been signed in from this device

When verificationState is TCVerificationState.otpInitiated, you will also receive an additional parameter for the time to live i.e TTL (in seconds) which can be fetched using:- Swift TCTrueSDK.sharedManager().tokenTtl() Objective C [[TCTrueSDK sharedManager] tokenTtl];

This value determines the amount of time left to complete the verification. You can use this value to show a waiting message to your user before they can try for another attempt. Once the TTL expires, you can either auto-retry the verification by calling the requestVerification() method automatically with the same input parameters OR you can also take the user back to the number input screen to enter a different number for verification.

Once the OTP is initiated, allow the user to enter the OTP, first name and last name.

When the verification status is TCVerificationStateVerifiedBefore or TCVerificationStateVerificationComplete, it means that the user verification via Truecaller SDK is complete. In these cases, the SDK will share an additional access token with your application, which you may then use to validate the response at your server end. To fetch the access token, you may use the following code snippet:

Swift TCTrueSDK.sharedManager().accessTokenForOTPVerification()

Objective C [[TCTrueSDK sharedManager] accessTokenForOTPVerification];

After fetching the access token, you may perform the server side validation by referring to the steps mentioned in the later part of the documentation here. Below mentioned didFailToReceiveTrueProfileWithError() method will be called when some error has occurred while verifying the provided mobile number. You will receive the appropriate error message from TCError using TCError.getErrorCode(). For details of different possible error types you may encounter, please refer to the next section

Swift

func didFailToReceiveTrueProfileWithError(_ error: TCError)

Objective C

- (void)didFailToReceiveTrueProfileWithError:(nonnull TCError *)error

Last updated