This pattern breaks a locally-defined flow into sections your app runs one at a time. Control returns to your app between sections, so you can display your own intermediate UI, run business logic, or branch based on intermediate results before starting the next section.
Use this pattern when you need to interleave your own UI or logic with the SDK modules, or when you want to split a long flow into discrete steps.
Prerequisite
The SDK must be initialized before you start a session. See Installation for the initializeSDK() call and its arguments.
Lifecycle
The step-by-step pattern uses five methods, called in this order:
setupOnboardingSession(): Create the session. Returns aninterviewIdandtoken.startOnboardingSection(): Run one section. This method can be called multiple times; each method runs only one section at a time. Wait for each section's callback before starting the next.getUserScore(): Fetch verification scores and results. Skip if you don't need scores, or if you use the inlineuserScoremodule in a section.finishOnboarding(): Finalize the session. Call exactly once, after all sections succeed.deleteUserLocalData(): Clear local cache. Skip if you don't need local cleanup.
Walkthrough
Step 1: Set Up the Session
let sessionConfig = {
configurationId: "your-flow-id", // optional
externalId: "your-external-id", // optional
e2eEncryptionEnabled: false, // optional
region: "ALL" // optional
};
cordova.exec(
function (data) {
console.log("Session ready. interviewId:", data.interviewId, "token:", data.token);
runFirstSection();
},
function (err) { console.log("setupOnboardingSession error:", err); },
"Cplugin",
"setupOnboardingSession",
[sessionConfig]
);
Step 2: Run a Section
function runFirstSection() {
let flowConfig = [
{ module: "addId", showIdTypeChooser: "true" },
{ module: "addSelfieScan" },
{ module: "addFaceMatch", matchType: "idSelfie" }
];
let recordSessionConfig = { recordSession: "false", forcePermissions: "false" };
let sectionTag = "identity-section-001";
cordova.exec(
function (result) {
console.log("Section status:", result.status);
console.log("Section tag:", result.sectionTag);
console.log("Front ID:", result.frontIdData);
console.log("Face match:", result.faceMatchData);
// Call startOnboardingSection again for the next section,
// or proceed to finishing the session.
finishSession();
},
function (error) {
// Typed error string, e.g. "permissionsDenied", "sslPinningFailed", "faceAuthenticationFailed"
console.log("Section error:", error);
},
"Cplugin",
"startOnboardingSection",
[flowConfig, recordSessionConfig, sectionTag]
);
}
Step 3: Fetch the User Score (Optional)
function fetchScore() {
cordova.exec(
function (result) {
console.log("Score:", JSON.stringify(result));
cleanup();
},
function (error) {
console.log("getUserScore error:", error);
},
"Cplugin",
"getUserScore",
["fast"] // "fast" | "accurate"
);
}
Step 4: Finish the Session
function finishSession() {
cordova.exec(
function () {
console.log("Onboarding finished");
fetchScore(); // optional, only if you need scores
},
function (err) { console.log("finishOnboarding error:", err); },
"Cplugin",
"finishOnboarding",
[]
);
}
Step 5: Delete Local Data (Optional)
function cleanup() {
cordova.exec(
function () { console.log("Local data deleted"); },
function (err) { console.log("deleteUserLocalData error:", err); },
"Cplugin",
"deleteUserLocalData",
[]
);
}
Notes
- You can start multiple sections, but only one at a time. Wait for each section's callback before starting the next.
- Section result payloads vary depending on which modules ran in the section. See Results for the full structure.
Related Pages
- Modules: Every module available in
flowConfigand its parameters. - Results: The structure of section results and the list of error strings.
- API Reference: The full signatures of
setupOnboardingSession(),startOnboardingSection(),finishOnboarding(),getUserScore(), anddeleteUserLocalData().