By default, the React Native SDK initializes with an API key. If your backend creates onboarding sessions and provides session tokens to your app, you can initialize the SDK without an API key and use the Sections API to run the flow.
This setup is useful when your backend manages session creation, you want to avoid embedding an API key in your app, or you need session tokens that are scoped to individual users.
Initialize without an API key
Omit the key field from apiConfig:
try {
await IncodeSdk.initialize({
testMode: false,
apiConfig: {
url: 'YOUR_API_URL',
},
});
} catch (error) {
const e = error as IncodeSdkInitError;
console.error(`${e.code} - ${e.message}`);
}
Set up the session with a token
Pass the backend-created token to setupOnboardingSession:
const session = await IncodeSdk.setupOnboardingSession({
sessionConfig: {
token: 'YOUR_TOKEN',
},
});
Run the flow with sections
After the session is set up, use the Sections API to run the flow. Call startOnboardingSection() for each section, then finishOnboardingFlow() when all sections are complete:
await IncodeSdk.startOnboardingSection({
flowConfig: [
{ module: 'IdScan', showTutorial: false },
{ module: 'SelfieScan', showTutorial: false },
],
});
await IncodeSdk.faceMatch();
await IncodeSdk.finishOnboardingFlow();
For the full Sections API walkthrough, see Configure Flows Locally and Run Step by Step.