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).
// On the Android SDK, the email verification process is integrated into the SDK. // Simply open it and complete the flow.account.openEmailVerificationFlow{isSuccess,error->if(isSuccess){coroutineScope.launch(Dispatchers.Main){Toast.makeText(applicationContext,"Email verification successfully",Toast.LENGTH_LONG).show()}}}
letemailDTO=DataObject.Builder().withData("bob@test.com".data(using:.utf8)).withMineType("text/plain").build()letcodeDTO=DataObject.Builder().withData("123456".data(using:.utf8)).withMineType("text/plain").build()letproofs=[Constants.SUBJECT_EMAIL:emailDTO,Constants.SUBJECT_SECURITY_CODE:codeDTO,]letverificationRequest=VerificationRequest.Builder().withTypes([CredentialType.Email]).withEvidence(proofs).build()// send the requestTask(priority:.background,operation:{letmessageId=tryawaitaccount.send(toAddress:toAddress,message:verificationRequest))})
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}")}}}