Job Submission

The job submission method sends the information to the Smile ID servers for processing and returns results when done. To improve UX, there are event-based callbacks during this process.

Import the Library

import RnSmileId from "rn-smile-id";

Submit the Job

const result = await RnSmileId.submitJob(
  callbackUrl: string, // optional, pass '' when not available
  geoInfo: object, // optional, pass {} when not available
  idInfo: object, // optional, pass {} when not available
  isProduction: boolean,
  jobStatusPollingTimeoutMillis: number // optional, pass 0 when not available
  jobType: number,
  partnerParams: object, // optional, pass {} when not available
  tag: string,
);
  • tag: Required. If this job type involves a selfie, it must be a tag that has already captured a job before this method is called.

  • jobType: Required. Must be a valid job type as listed on the products page on the left.

  • isProduction: Required. Boolean value (true or false). If false, the jobs will be sent to sandbox; if true, jobs will be sent to production.

  • partnerParams: (Optional) A JavaScript object as shown below. This object can have a user_id and/or a job_id, all of which, if not passed, will be autogenerated. It can also take other parameters that you may need back to identify the job, as long as they do not conflict with the reserved keys _job_id, user_id, job_type.

{
  "job_id": "<YOUR JOB ID>",
  "user_id": "<YOUR USER ID>",
  "...": "..."
}
  • idInfo: (Optional) Mandatory for document verification but used as needed for job type Enhanced KYC + SmartSelfie. The object is described below:

{
  "allow_re_enroll": true, // allow the user to be re-enrolled, do not pass if the user has not been enrolled
  "country": "<country>",
  "email": "<email>",
  "first_name": "<firstName>",
  "id_number": "<idNumber>",
  "id_type": "<idType>",
  "last_name": "<lastName>",
  "middle_name": "<middleName>",
  "...": "..."
}
  • geoInfo: (Optional) Used if you need to record geo-location information associated with the job.

{
  "accuracy": number,
  "altitude": number,
  "isGeoPermissionGranted": boolean,
  "lastUpdate": string,
  "latitude": number,
  "longitude": number
}
  • callbackUrl: (Optional) Sets the URL to send the callback results to. For more information on the callback URL, please read here.

  • jobStatusPollingTimeoutMillis: (Optional) Pass 0 if not needed. This will be the time to wait for job status polling. Note that if set to a smaller number, this will return a complete false result from job status, and results will be delivered to the callback.

Events

During the processing of the job, the SDK provides different events to signify the stage where the job is currently at.

The SIDReactNativeEventEmitter provides these events and is accessible via the following steps:

Import the NativeModules Component

import { NativeEventEmitter, NativeModules } from "react-native";

Setup the Emitter

const eventEmitter = new NativeEventEmitter(
  NativeModules.SIDReactNativeEventEmitter,
);

Listen to the Upload Event

eventEmitter.addListener("UploadListener", (event) => {
  console.log(event.status);
});

This will return an integer wrapped in a string signifying how much of the zip file has been uploaded, represented as a percentage relative to the file size.

Listen to the Completion Event

eventEmitter.addListener("UploadListener", (event) => {
  console.log(event.status);
});

This will return a status of "done" when the upload is finished.

Get Results

The method will return a result accessible in our example as result.result. This object is documented in the return value section of your chosen product type under the products section on the left. The most important of these is the result.ResultCode, which shows the state and result from the job you have just run.

Last updated