TcSdk class

Constructors

TcSdk()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

generateRandomCodeVerifier Future
This utility method generates a random code verifier string using SecureRandom as the source of entropy with 64 as the default entropy quantity. You can either generate your own code verifier or use this utility method to generate one for you. NOTE: Store the code verifier in the current session since it would be required later to generate the access token.
no setter
getAuthorizationCode → dynamic
After checking isUsable, you can invoke Truecaller's OAuth consent screen dialog in your app flow by calling the following method The result will be returned asynchronously via streamCallbackData stream
no setter
isOAuthFlowUsable Future
Once you initialise the Truecaller SDK using the initializeSDK method, and if you are using the SDK for verification of only Truecaller users ( by setting the sdkOptions scope as TcSdkOptions.OPTION_VERIFY_ONLY_TC_USERS, you can check if the Truecaller app is present on the user's device and whether the user has a valid account state or not and whether the OAuth flow is supported or not using the following method
no setter
streamCallbackData Stream<TcSdkCallback>
Once you call getAuthorizationCode, you can listen to this stream to determine the result of the action taken by the user. TcSdkCallbackResult.success means the result is successful and you can now fetch the user's access token using the authorization code from TcSdkCallback.tcOAuthData TcSdkCallbackResult.failure means the result is failure and you can now fetch the result of failure from TcSdkCallback.error TcSdkCallbackResult.verification will be returned only when using TcSdkOptions.OPTION_VERIFY_ALL_USERS which indicates to verify the user manually
no setter

Static Methods

generateCodeChallenge(String codeVerifier) Future
This utility method produces a code challenge from the supplied code verifiercodeVerifier using SHA-256 as the challenge method and Base64 as encoding if the system supports it. NOTE: All Android devices should ideally support SHA-256 and Base64, but in rare case if the doesn't, then this method would return null meaning that you can’t proceed further. Please ensure to have a null safe check for such cases.
initializeSDK({required int sdkOption, int consentHeadingOption = TcSdkOptions.SDK_CONSENT_HEADING_LOG_IN_TO, int footerType = TcSdkOptions.FOOTER_TYPE_ANOTHER_MOBILE_NO, int ctaText = TcSdkOptions.CTA_TEXT_PROCEED, int buttonShapeOption = TcSdkOptions.BUTTON_SHAPE_ROUNDED, int? buttonColor, int? buttonTextColor}) → dynamic
This method has to be called before anything else. It initializes the SDK with the customizable options which are all optional and have default values as set below in the method
requestVerification({required String phoneNumber, String countryISO = "IN"}) → dynamic
This method will initiate manual verification of phoneNumber asynchronously for Indian numbers only so that's why default countryISO is set to "IN". The result will be returned asynchronously via streamCallbackData stream Check TcSdkCallbackResult to understand the different verifications states. This method may lead to verification with a SMS Code (OTP) or verification with a CALL, or if the user is already verified on the device, will get the call back as TcSdkCallbackResult.verifiedBefore in streamCallbackData
setCodeChallenge(String codeChallenge) → dynamic
Set your own code challenge or use the utility method generateRandomCodeVerifier to generate one for you and set it via codeChallenge to this method Set it before calling getAuthorizationCode
setLocale(String locale) → dynamic
Customise the consent screen dialog in any of the supported Indian languages by supplying locale to the method. NOTE: Default value is en Set it before calling getAuthorizationCode
setOAuthScopes(List<String> scopes) → dynamic
Set the list of scopes to be requested using scopes. Set it before calling getAuthorizationCode
setOAuthState(String oAuthState) → dynamic
Set a unique state parameter oAuthState & store it in the current session to use it later in the onSuccess() callback method of the TcOAuthCallback to match if the state received from the authorization server is the same as set here to prevent request forgery attacks. Set it before calling getAuthorizationCode
verifyMissedCall({required String firstName, required String lastName}) → dynamic
Call this method after requestVerification to complete the verification if the number has to be verified with a missed call. i.e call this method only when you receive TcSdkCallbackResult.missedCallReceived in streamCallbackData. To complete verification, it is mandatory to pass firstName and lastName of the user
verifyOtp({required String firstName, required String lastName, required String otp}) → dynamic
Call this method after requestVerification to complete the verification if the number has to be verified with an OTP. i.e call this method when you receive either TcSdkCallbackResult.otpInitiated or TcSdkCallbackResult.otpReceived in streamCallbackData. To complete verification, it is mandatory to pass firstName and lastName of the user with the otp code received over SMS