Document
To use any Sybrin SDK you will need a Sybrin issued license. You can have a look at our licensing page to request one.
Using the license provided you will need to build and instance of the SybrinIdentityConfiguration class that will help with configuring the SDKs' behavior.
SybrinIdentityConfiguration sic = new SybrinIdentityConfiguration
.Builder(<sybrin_license_here>)
.build();
To start scanning a document you will need to get an instance of the SybrinIdentity class using the configuration built before. With this object you will be able to call the
scanDocument
method, which has a Document as a parameter. Finally you can register for the 3 different callbacks right on the method call.SybrinIdentity si = SybrinIdentity.getInstance(Activity.this, sic);
si.scanDocument(Document.SouthAfricaIDCard)
.addOnSuccessListener(new IdentityScanner.OnSuccessListener<DocumentModel>() {
@Override
public void onSuccess(DocumentModel result) {
// Handle success
}
})
.addOnFailureListener(new IdentityScanner.OnFailureListener() {
@Override
public void onFailure(IdentityException ie) {
// Handle failure
}
})
.addOnCancelListener(new IdentityScanner.OnCancelListener() {
@Override
public void onCancel() {
// Handle cancelation
}
});
Subscribing to any of the callbacks on the
scanDocument
method is optional.A custom cutout can be specified for Generic Document before scanning is started. The specific cutout overlay to use for Generic Document can be specified programmatically as follows.
SybrinIdentity si = SybrinIdentity.getInstance(Activity.this, sic);
Document genericDocument = Document.GenericDocument;
genericDocument.setCutoutType(CutoutType.ID_CARD);
si.scanDocument(genericDocument)
.addOnSuccessListener(new IdentityScanner.OnSuccessListener<DocumentModel>() {
@Override
public void onSuccess(DocumentModel result) {
// Handle success
}
})
.addOnFailureListener(new IdentityScanner.OnFailureListener() {
@Override
public void onFailure(IdentityException ie) {
// Handle failure
}
})
.addOnCancelListener(new IdentityScanner.OnCancelListener() {
@Override
public void onCancel() {
// Handle cancelation
}
});
The cutout type specified for the example is the ID_CARD cutout but any of the cutout
There are 3 different callbacks that can be subscribed to. They are as follows:
When the SDK has completed the scanning process the result of that process will be posted to the
OnSuccessListener.onSuccess
callback. The DocumentModel that is returned is a parent class to all country specific classes.Lets say that you provide the
scanDocument
method with the Document.SouthAfricaIDCard
parameter. The result that will be posted to the OnSuccessListener
will be of type SouthAfricaIDCardModel, but is returned in its parent form. To access all the data specific to the SouthAfricaIDCardModel you will need to cast the DocumentModel to that type. Luckily, we have made this easy with the castToModel
method.si.scanDocument(Document.SouthAfricaIDCard)
.addOnSuccessListener(new IdentityScanner.OnSuccessListener<DocumentModel>() {
@Override
public void onSuccess(DocumentModel result) {
// Cast model
SouthAfricaIDCardModel saModel = result.castToModel(SouthAfricaIDCardModel.class);
String rsaCode = saModel.getRsaCode();
}
});
When the SDK encounters an error an IdentityException is posted to the
OnFailureListener.onFailure
callback. The IdentityException will contain all the needed information to help solve the issue causing the error.si.scanDocument(Document.SouthAfricaIDCard)
.addOnFailureListener(new IdentityScanner.OnFailureListener() {
@Override
public void onFailure(IdentityException ie) {
// Get error message
String error = ie.getLocalizedMessage();
}
});
When the scanning process is interrupted by the user by pressing the back button the SDK will post a response to the
OnCancelListener.onCancel
callback. This callback has no return value.si.scanDocument(Document.SouthAfricaIDCard)
.addOnCancelListener(new IdentityScanner.OnCancelListener() {
@Override
public void onCancel() {
// Do something when scanning is cancelled
}
});
Activity.java
SybrinIdentityConfiguration sic = new SybrinIdentityConfiguration
.Builder(<sybrin_license_here>)
.build();
SybrinIdentity si = SybrinIdentity.getInstance(Activity.this, sic);
si.scanDocument(Document.SouthAfricaIDCard)
.addOnSuccessListener(new IdentityScanner.OnSuccessListener<DocumentModel>() {
@Override
public void onSuccess(DocumentModel result) {
// Cast model
SouthAfricaIDCardModel saModel = result.castToModel(SouthAfricaIDCardModel.class);
String rsaCode = saModel.getRsaCode();
}
})
.addOnFailureListener(new IdentityScanner.OnFailureListener() {
@Override
public void onFailure(IdentityException ie) {
// Get error message
String error = ie.getLocalizedMessage();
}
})
.addOnCancelListener(new IdentityScanner.OnCancelListener() {
@Override
public void onCancel() {
// Do something when scanning is cancelled
}
});
Last modified 3mo ago