Once you receive a callback in your VerificationCallback instance with the callbackType TYPE_MISSED_CALL_RECEIVED
, you can complete the verification process by calling the following method from within your activity :
Copy
You need to create a TrueProfile instance by passing the user's first and last name as defined above.
Please note that the first name and last name values to be passed in the above method call need to follow below mentioned rules :
The strings need to contains at least 1 alphabet, and cannot be completely comprised of numbers or special characters.
String length should be less than 128 characters.
First name is a mandatory field, last name can be empty ( but non nullable ).
This section defines the steps that can be used to trigger verification of non Truecaller app users which will be powered via Truecaller's drop call based verification flow
In order to verify both the Truecaller users (via OAuth Flow) and the non-Truecaller users (via manual verification), follow these steps :
Enable the Non Truecaller user verification capability for your app, by going to your project on the Truecaller developer portal and navigating to the bottom section.
Configure sdkOptions in the TcSdkOptions Builder and supply a value of TcSdkOptions.OPTION_VERIFY_ALL_USERS to it like below.
Configure permissions required by the SDK :
Once you receive a callback in the TcOAuthCallback#onVerificationRequired()
, you can initiate the verification for the user by calling the following method:
Here -
the first parameter is the country code of the mobile number for which the verification needs to be triggered
the second parameter (PHONE_NUMBER_STRING) is the mobile number to be verified. Please ensure proper validations are in place so as to send correct phone number string to the above method, otherwise an exception would be thrown
the third parameter is an instance of VerificationCallback as defined here
the fourth parameter is an instance of FragmentActivity
Please note that Truecaller OAuth SDK v3.0.0 currently supports the verification for non-Truecaller users for Indian numbers only
Once you initiate the verification via TcSdk.getInstance().requestVerification()
method, you will receive either a callback in your VerificationCallback
instance with a specific requestType
as described below
onRequestSuccess() method is called under any of the following scenarios -
When drop call is successfully initiated for the input mobile number. In this case, you will get the callbackType as VerificationCallback.TYPE_MISSED_CALL_INITIATED
When drop call is successfully detected on that device by the SDK present in your app. In this case, you will get the callbackType as VerificationCallback.TYPE_MISSED_CALL_RECEIVED
When the verification is successful for a particular number. In this case, you will get the callbackType as VerificationCallback.TYPE_VERIFICATION_COMPLETE
When the user is already verified on that particular device before. In this case, you will get the callbackType as VerificationCallback.TYPE_PROFILE_VERIFIED_BEFORE
When callbackType is VerificationCallback.TYPE_MISSED_CALL_INITIATED
, you will receive an additional parameter for the time to live i.e TTL (in seconds) which is passed as String extra in the VerificationDataBundle
of onRequestSuccess()
.
This value determines 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.
When the callbackType is VerificationCallback.TYPE_ALREADY_VERIFIED_BEFORE
or VerificationCallback.TYPE_VERIFICATION_COMPLETE
, 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 :
Post 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
onRequestFailure() method will be called when some error has occurred while verifying the provided mobile number. You will receive the appropriate error message from TrueException using TrueException#getExceptionMessage().For details of different possible error types you may encounter, please refer to the TrueException
Handling error responses for cases of verifying non-Truecaller users
Error Code | Error Message | Description |
---|---|---|
Once the SDK shares the accessToken for any user verified via drop call based verification flow, you can verify the authenticity of the access token by making API call from your server to Truecaller's server. The following endpoint will return phone number and country code for the given access token.
API Endpoint:
REQUEST :
Method : GET
Header Parameters:
Request Path Parameters:
RESPONSE:
200 OK - If access token is valid
404 Not Found - If your credentials are not valid
404 Not Found - If access token is invalid
500 Internal Error - for any other internal error
4
"Desired permissions are missing"
When the requisite permissions are missing or not granted while making the verification request
6
“Sim state is not ready”
When the SIM state on the device is not ready
7
“Airplane mode is ON”
When the device is on airplane mode, hence causing missed call to not go through
2
"Phone number limit reached”
When the used mobile number has exceeded the maximum number of allowed verification attempts within a span of 24 hours from the time the first verification attempt was made
2
“Request id limit reached”
When the used device exceeds the maximum number of allowed verification attempts in a span of 24h
2
“Invalid partner credentials.
When the partner key ( app key ) you have configured in your project is incorrect. Visit here for more info
2
“Something went wrong: Failed to create installation.”
In case of Truecaller internal service error
2
“Invalid phone number”
When the input mobile number is not a valid mobile number
2
“Profile has not been created yet”
When the user has been successfully verified, but for some reason their profile is not created which could be due to incorrect profile data while creating TrueProfile() in verifyMissedCall method or due to network issues
5
“Invalid Name”
When the string entered in the profile builder method doesn’t follow the validation checks :
{
min 1 char, max 128, at least 1 alphabet required with optional numeric and special chars,
cannot be all numeric or all special characters, but can be all alphabets
}
Refer here for more info
Parameter Name
Required
Description
Example
clientId
yes
Client ID
zHTqS70ca9d3e016946f19a65b01dRR5e56460
Parameter Name
Required
Description
Example
accessToken
yes
token granted for the partner for the respective user number that initiated login
"71d8367e-39f7-4de5-a3a3-2066431b9ca8"