Passport

Configuration

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.

For example:

SybrinIdentityConfiguration sic = new SybrinIdentityConfiguration
        .Builder(<sybrin_license_here>)
        .build();

To see the full range of configuration available please visit the SybrinIdentityConfiguration page

Calling feature

To start scanning a passport 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 scanPassport method, which has a Country as a parameter. Finally you can register for the 3 different callbacks right on the method call.

For example:

SybrinIdentity si = SybrinIdentity.getInstance(Activity.this, sic);
 
si.scanPassport(Country.SouthAfrica)
        .addOnSuccessListener(new IdentityScanner.OnSuccessListener<PassportModel>() {
            @Override
            public void onSuccess(PassportModel 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 scanPassport method is optional.

Handling callback responses

There are 3 different callbacks that can be subscribed to. They are as follows:

OnSuccessListener

When the SDK has completed the scanning process the result of that process will be posted to the OnSuccessListener.onSuccess callback. The PassportModel that is returned is a parent class to all country specific passport classes.

Lets say that you provide the scanPassport method with the Country.SouthAfrica parameter. The result that will be posted to the OnSuccessListener will be of type SouthAfricaPassportModel, but is returned in its parent form. To access all the data specific to the SouthAfricaPassportModel you will need to cast the PassportModel to that type. Luckily, we have made this easy with the castToModel method.

For example:

si.scanPassport(Country.SouthAfrica)
        .addOnSuccessListener(new IdentityScanner.OnSuccessListener<PassportModel>() {
            @Override
            public void onSuccess(PassportModel result) {
            
                // Cast model
                SouthAfricaPassportModel spModel = result.castToModel(SouthAfricaPassportModel.class);
                String idNumber = spModel.getIdentityNumber();    
            }
        });

OnFailureListener

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.

For example:

si.scanPassport(Country.SouthAfrica)
        .addOnFailureListener(new IdentityScanner.OnFailureListener() {
            @Override
            public void onFailure(IdentityException ie) {
            
                // Get error message
                String error = ie.getLocalizedMessage();
            }
        });

If you would like to report a bug, contact us!

OnCancelListener

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.

For example:

si.scanPassport(Country.SouthAfrica)
        .addOnCancelListener(new IdentityScanner.OnCancelListener() {
            @Override
            public void onCancel() {
                // Do something when scanning is cancelled
            }
        });

Full example

Activity.java
SybrinIdentityConfiguration sic = new SybrinIdentityConfiguration
        .Builder(<sybrin_license_here>)
        .build();
        
SybrinIdentity si = SybrinIdentity.getInstance(Activity.this, sic);
 
si.scanPassport(Country.SouthAfrica)
        .addOnSuccessListener(new IdentityScanner.OnSuccessListener<PassportModel>() {
            @Override
            public void onSuccess(PassportModel result) {
            
                // Cast model
                SouthAfricaPassportModel spModel = result.castToModel(SouthAfricaPassportModel.class);
                String idNumber = spModel.getIdentityNumber();    
            }
        })
        .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
            }
        });