Skip to main content

Signature

This module creates a canvas, and lets the users upload their signatures.

Flow overviewFlowchart of this module's usage within the SDK flow. Expand to view it, click the chart to enlarge.

Signature flow

  • G1–G3: configure (with the optional SSL pinning first; no dynamic feature needed), set the event listener, start the session.
  • G4: Signature().start(...) with the number of signatures; show the returned fragment.
  • G5: your Confirm button calls confirm(context), your Clean button calls clean(); each confirm reaches the start callback with the count so far.
  • G6: when the count reaches the requested number, remove the fragment and upload; if it fails, do not call upload() again: call resetCountOfSignature() and open the canvas again.
  • Other modules may come before or after the signature, in the order your flow needs.

Preparation for starting the signature module​

↑ Flow step G4

start method returns a Fragment that you can use to capture set number of signatures. When number of signature will be taken is equal to your goal you can call the upload function inside the callback as below.

Add the imports below (Kotlin users can drop the trailing semicolons):

import ai.amani.sdk.Amani;
import android.util.Log;

Then capture the signatures and upload them as shown below:

int NUMBER_OF_SIGNATURE_WILL_BE_TAKEN = 1;
Amani.sharedInstance().Signature().start(this, NUMBER_OF_SIGNATURE_WILL_BE_TAKEN, (bitmap, countOfSignature) -> {
if (bitmap != null) {
if (NUMBER_OF_SIGNATURE_WILL_BE_TAKEN == countOfSignature) {
Amani.sharedInstance().Signature().upload(isSuccess -> {
if (isSuccess) {
Log.d(TAG, "Signature is uploaded");
} else {
Log.d(TAG, "Signature upload failed");
}
});
}
}
});
note

A true result means the document reached the server, not that it was approved. Verification runs asynchronously on the backend, so the outcome arrives later through the event listener rather than here.

Alternatively, if you need the ID of the uploaded document, override the second cb(...) method instead. Everything else stays the same:

Amani.sharedInstance().Signature().upload(new IUploadCallBack() {
@Override
public void cb(boolean isSuccess) { }

@Override
public void cb(boolean isSuccess, @Nullable String documentID) {
// isSuccess is true when the document is uploaded
// documentID is the ID of the uploaded document
}
});

Adding Confirm and Clean button​

↑ Flow step G5

You should add two buttons with label of clear and confirm.

Cleaning the Canvas​

You can call clean function, on a button that sits on the top of the fragment.

Amani.sharedInstance().Signature().clean();

Confirm​

To confirm the current signature user must press the confirm button and call this function.

Amani.sharedInstance().Signature().confirm(context);

Resetting the count of signatures​

If you want to reset the process in the middle of capturing, you must call resetCountOfSignature() method. It should be used when necessary as it's use is optional.

Amani.sharedInstance().Signature().resetCountOfSignature();

Uploading the Signatures​

↑ Flow step G6

Add the imports below:

import ai.amani.sdk.Amani
import android.util.Log

Then upload the captured signatures as shown below:

Amani.sharedInstance().Signature().upload { isSuccess: Boolean ->
Log.d(TAG, "upload isSuccess $isSuccess")
}