Job Submission

The job submission method is the method that 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.

Import the library

import RnSmileId from 'rn-smile-id';

Submit the Job

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

  • jobType => required and must be a valid job type as listed on the products page on the left

  • isProduction => required and is a boolean 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 below. This object can have a user_id and or a jobid all of which if not passed will be autogenerated. It can also take other parameters which you may need back to identify the job as long are not with the reserved keys job_id,user_id,job_type

{
    "job_id":<YOUR JOB ID>,
    "user_id":<YOUR USER ID>,
    ...
    "<OTHER_KEY>":<OTHER_KEY_VALUE>
    ...
}
  • idInfo => (optional) This is mandatory for document verification but is used as the case may be for job type Enhanced KYC + SmartSelfie. the object is described below

{
  country: <country>,
  id_type: <idType>,
  id_number: <idNumber>,
  first_name: <firstName>,
  middle_name: <middleName>,
  last_name: <lastName>,
  email: <email>,
  allow_re_enroll:<true/false>, //allow the user to be reenrolled
                                //do not pass if the user has not been enrolled
  "<OTHER_KEY>":<OTHER_KEY_VALUE>
}
  • geoInfo => (optional) This is optional and is used if you need to record geo location information associated with the job

    {
      accuracy: number
      altitude: number,
      latitude: number,
      longitude: number,
      lastUpdate: string,
      isGeoPermissionGranted: boolan
    }
  • callBackUrl => (optional) this will set the url to send the call back results to, for more information on the call back url please read here

  • jobStatusPollingTimeoutMillis => (optional) pass 0 if not needed. This will be the time to wait for job status polling , note 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 is the object that 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 a integer wrapped in a string signifying how much of the zip file has been uploaded in a percentage which is relative to the file size

Listen to the Completion Event

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

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

Get Results

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

Last updated