Skip to main content

Android KYC components

KYC due diligence is one of the steps required to onboard consumers onto your app. Weavr provides a KYC component that you can embed in your app. This lets you provide a seamless experience to your user while capturing the required documentation to verify their identity.

Start KYC

Once setup is done you are ready to present the SDK on the screen. Please see this code example for a quick start.

Customizing the look and feel of the KYC component

Refer to SumSub MobileSDK Documentation for detailed information on how to customize UI components in your app.

To create Weavr theme object, you can use:

val colors = mutableMapOf<WeavrSNSColorElement, WeavrSNSColor>()
colors[WeavrSNSColorElement.BACKGROUND_COMMON] = WeavrSNSColor(
Color.parseColor("#ff0000"),
Color.parseColor("#ffff00")
)

val fonts = mutableMapOf<WeavrSNSTypographyElement, WeavrSNSFont>()
fonts[WeavrSNSTypographyElement.HEADLINE1] = WeavrSNSFont(TypefaceMONOSPACE, 20)

val metrics = mutableMapOf<WeavrSNSMetricElement, Any>()
metrics[WeavrSNSMetricElement.ACTIVITY_INDICATOR_STYLE] = SNSThemeMetric.Size.LARGE
metrics[WeavrSNSMetricElement.CARD_CORNER_RADIUS] = 0f
metrics[WeavrSNSMetricElement.DOCUMENT_TYPE_CARD_STYLE] = SNSThemeMetric.CardStyle.DEFAULT

val theme = WeavrSNSTheme(colors = colors, fonts = fonts, metrics = metrics)

You can customize your fonts, colors, and icons. e.g.:

UXComponents.kyc.startKYC(
this,
reference = "110968060296953922",
kycLevel = KYC_LEVELS.KYC_LEVEL_2,
kycListeners = kycListeners,
theme = theme,
onKycCompleteListener =
object : OnKycCompleteListener<String, ErrorResponse> {
override fun onKYCSuccessful(result: String) {
Log.d(Tag, "onKYCSuccessful: $result")
}

override fun onKYCFailed(error: ErrorResponse) {
Log.d(Tag, "onKYCFailed: $error")
Toast.makeText(this@MainActivity, error.message, Toast.LENGTH_SHORT).show()
}
},

)

Also, you can customize the Text’s shape, font, and colors by modifying the Theme options. e.g.:

<style name="Base.Theme.SNSCore" parent="Base.Theme.MaterialThemeBuilder">
<item name="colorPrimary">@color/sns_color_primary_50</item>
<item name="colorPrimaryVariant">@color/sns_color_primary_60</item>
<item name="colorSecondary">@color/sns_color_primary_50</item>
....

Example: Add KYC Listeners

val kycListeners: KYCListeners =
object : KYCListeners {
override fun onWeavrKYCCompleteHandler(
weavrKYCCompleteHandler: WeavrKYCCompleteHandler
) {
when (weavrKYCCompleteHandler) {
is WeavrKYCCompleteHandler.AbnormalTermination ->
Log.d(
Tag,
"onException: ${weavrKYCCompleteHandler.exception}"
)
is WeavrKYCCompleteHandler.SuccessTermination ->
Log.d(
Tag,
"onSuccess: ${weavrKYCCompleteHandler.stateName}"
)
}
}

override fun onWeavrKYCSDKErrorHandler(kycException: KYCException) {
when (kycException) {
is KYCException.API ->
Log.d(
Tag,
"onWeavrKYCSDKErrorHandler: Api exception. ${kycException.description}"
)
is KYCException.Network ->
Log.d(
Tag,
"onWeavrKYCSDKErrorHandler: Network exception. ${kycException}"
)
is KYCException.UnKnown ->
Log.d(
Tag,
"onWeavrKYCSDKErrorHandler: UnKnown exception. ${kycException}"
)
}
}

override val tokenExpirationHandler: WeavrKYCTokenExpirationHandler
get() =
object : WeavrKYCTokenExpirationHandler {
override fun onTokenExpired(): String? {
// Access token expired
// get a new one and pass it to the callback to re-initiate the
// SDK
// val newToken = "..." // get a ew token from your backend
return ""
}
}

override fun onKYCSDKStateChangeHandler(kycSdkState: KYCSDKState) {
when (kycSdkState) {
KYCSDKState.Ready -> Log.d(Tag, "SDK is ready")
is KYCSDKState.Failed -> {
when (kycSdkState) {
is KYCSDKState.Failed.ApplicantMisconfigured ->
Log.e(
Tag,
"onKYCSDKStateChangeHandler: ${kycSdkState.message}",
)
is KYCSDKState.Failed.ApplicationNotFound ->
Log.e(
Tag,
"onKYCSDKStateChangeHandler: ${kycSdkState.message}",
)
is KYCSDKState.Failed.InitialLoadingFailed ->
Log.e(
Tag,
"onKYCSDKStateChangeHandler: ${kycSdkState.message}",
kycSdkState.exception
)
is KYCSDKState.Failed.InvalidParameters ->
Log.e(
Tag,
"onKYCSDKStateChangeHandler: ${kycSdkState.message}",
)
is KYCSDKState.Failed.NetworkError ->
Log.e(
Tag,
"onKYCSDKStateChangeHandler: ${kycSdkState.message}",
kycSdkState.exception
)
is KYCSDKState.Failed.Unauthorized ->
Log.e(
Tag,
"onKYCSDKStateChangeHandler: Invalid token or a token can't be refreshed by the SDK. Please, check your token expiration handler",
kycSdkState.exception
)
is KYCSDKState.Failed.Unknown ->
Log.e(
Tag,
"onKYCSDKStateChangeHandler: Unknown error",
kycSdkState.exception
)
}
}
KYCSDKState.Initial ->
Log.d(Tag, "No verification steps are passed yet ")
KYCSDKState.Incomplete ->
Log.d(
Tag,
"Some but not all verification steps are passed over"
)
KYCSDKState.Pending -> Log.d(
Tag,
"Verification is in pending state"
)
KYCSDKState.FinallyRejected ->
Log.d(Tag, "Applicant has been finally rejected ")
KYCSDKState.TemporarilyDeclined ->
Log.d(Tag, "Applicant has been declined temporarily ")
KYCSDKState.Approved -> Log.d(
Tag,
"Applicant has been approved"
)
}
}

override fun onKYCEventHandler(kycEvent: KYCEvent) {
when (kycEvent) {
KYCEvent.SNSEventStepCompleted -> {
Log.d(Tag, "onEvent: step initiated")
}
KYCEvent.SNSEventStepInitiated -> {
Log.d(Tag, "onEvent: step completed")
}
}
}
}