Think of a verification request like asking someone for their ID.
You want to confirm a specific credential of theirs, say, their email address. You send a request to the issuer of the credential (the one who "issued their ID"). The issuer can either give a thumbs-up (approve) or thumbs-down (reject).
letemailDTO=DataObject.Builder().withData("bob@test.com".data(using:.utf8)).withContentType("text/plain").build()letcodeDTO=DataObject.Builder().withData("123456".data(using:.utf8)).withContentType("text/plain").build()letproofs=[Constants.SUBJECT_EMAIL:emailDTO,Constants.SUBJECT_SECURITY_CODE:codeDTO,]letverificationRequest=VerificationRequest.Builder().withTypes([CredentialType.Email]).withProofs(proofs).build()// send the requestTask(priority:.background,operation:{tryawaitself.account.send(message:verificationRequest,onAcknowledgement:{requestId,errorinprint("sent verification request: \(requestId) with error: \(error)")})})
casemessage.TypeCredentialVerificationResponse:response,err:=message.DecodeCredentialVerificationResponse(msg)iferr!=nil{// handle error}// Check the statuslog.Info("Response received with status","status",response.Status())// Validate each credentialfor_,c:=rangeresponse.Credentials(){err=c.Validate()iferr!=nil{// handle errorcontinue}claims,err:=c.CredentialSubjectClaims()iferr!=nil{// handle errorcontinue}// Access specific claimsprintln(claims["email"])}
ContentType.CREDENTIAL_VERIFICATION_RESPONSE->{valresponse=CredentialVerificationResponse.decode(content)println("Response received with status: ${response.status().name}")// Validate each credentialresponse.credentials().forEach{credential->try{credential.validate()valclaims=credential.credentialSubjectClaims()// Access specific claimsprintln("Email: ${claims["email"]}")}catch(ex:Exception){println("Failed to validate credential: ${ex.message}")}}}
account.setOnResponseListener{msg->when(msg){isVerificationResponse->{println("Response received with status:${msg.status().name}")msg.credentials().forEach{credential->println("credential types: ${credential.types()}")credential.claims().forEach{claim->println("email value ${claim.value()}")}}}}}
account.setOnResponseListener{messageinprint("setOnResponseListener: \(message)")switchmessage{caseisVerificationResponse:letresponse=messageas!VerificationResponseprint("Handle verification response: \(response)")default:print("TODO: Handle For other response: \(message)")break;}}
The Android and iOS SDKs provide a streamlined way to integrate identity verification flows into your mobile application. These flows support the capture and validation of the following user credentials: Email address, Passport, ID card
Integrate the SDK’s pre-built UI components into your app to guide users through each verification step. This includes interfaces for entering an email address, capturing images of passports or ID cards, and confirming submitted data.
After verification, the SDK stores the verified credentials securely in the device's local database. This can later be used to fulfill presentation requests.
Below are code examples in a simple MainActivity on how to integrate the email, document verification flow in the app.
classMainActivity:ComponentActivity(){overridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)// setup sdk and account valaccount=Account.Builder().setContext(applicationContext).setEnvironment(Environment).setSandbox(true).setStoragePath(storagePath.absolutePath).build()setContent{valcoroutineScope=rememberCoroutineScope()valnavController=rememberNavController()valselfModifier=SelfModifier.sdk()valclaims=remember{mutableStateListOf<Claim>()}// get verified credentials from sdkfunrefreshClaims(){valcredentials=account.credentialsByType()claims.clear()claims.addAll(credentials.flatMap{cred->cred.credentials.flatMap{it.claims()}})}NavHost(navController=navController,startDestination="main",modifier=Modifier.systemBarsPadding(),enterTransition={EnterTransition.None},exitTransition={ExitTransition.None}){// see the full UI in the example link above// integrate email verification flowaddEmailRoute(navController,route="emailRoute",selfModifier=selfModifier,account={account},onFinish={error->if(error==null){refreshClaims()// refresh email credentials to displaycoroutineScope.launch(Dispatchers.Main){Toast.makeText(applicationContext,"Email verification successfully",Toast.LENGTH_LONG).show()}}})// integrate passport, idcard verification flowaddDocumentVerificationRoute(navController,route="documentRoute",selfModifier=selfModifier,account={account},isDevMode={false},// true for testing onlyonFinish={error->if(error==null){refreshClaims()// refresh email credentials to displaycoroutineScope.launch(Dispatchers.Main){Toast.makeText(applicationContext,"Document verification successfully",Toast.LENGTH_LONG).show()}}})}}}}