@@ -4,36 +4,31 @@ import {
44 SafeAreaView ,
55 StatusBar ,
66 StyleSheet ,
7- useColorScheme ,
87 View ,
98} from 'react-native' ;
109import { EntrustIdv } from '@entrust.corporation/idvsdk-reactnative' ;
1110import type { Callbacks } from '@entrust.corporation/idvsdk-reactnative/callbacks/callbacks' ;
1211import { SafeAreaProvider } from 'react-native-safe-area-context' ;
1312import {
14- Welcome ,
15- FacePhoto ,
16- FaceMotion ,
17- type ClassicParameters ,
18- type Configuration ,
13+ Configuration ,
14+ StudioParameters ,
15+ ClassicParameters ,
16+ } from '@entrust.corporation/idvsdk-reactnative/SdkParameters' ;
17+ import { Document } from '@entrust.corporation/idvsdk-reactnative/steps/Document' ;
18+ import { FaceMotion } from '@entrust.corporation/idvsdk-reactnative/steps/Face' ;
19+ import { Welcome } from '@entrust.corporation/idvsdk-reactnative/steps/Welcome' ;
20+ import {
1921 Theme ,
20- MediaResult ,
21- } from '@entrust.corporation/idvsdk-reactnative/src/capture-api' ;
22- import { ThemeMode } from "@entrust.corporation/idvsdk-reactnative/src/capture-api/theming/Theme.ts" ;
23- import { ColorTokensKeys } from "@entrust.corporation/idvsdk-reactnative/src/capture-api/theming/ColorTokens.ts" ;
24-
25- // Create a SDK token for this applicant in your backend and use it here
26- const SDK_TOKEN = 'YOUR_SDK_TOKEN' ;
22+ ThemeMode ,
23+ } from '@entrust.corporation/idvsdk-reactnative/theming/Theme' ;
2724
28- // For Studio flows, create a Studio-type SDK token for this applicant instead (in your backend)
29- // Workflow Run ID is required for Studio-type SDK tokens and it's embedded in the studio token
30- // const STUDIO_TOKEN = 'YOUR_STUDIO_TOKEN ';
25+ // For Studio flows, use the SDK token generated during the workflow creation process and use it here
26+ // The workflow run ID is no longer required when Studio-type SDK tokens are used as it is embedded in the Studio token
27+ const studioToken = '<Your Studio token> ' ;
3128
32- const classicSteps = [
33- Welcome ( ) ,
34- FacePhoto ( { showIntro : false } ) ,
35- FaceMotion ( { showIntro : false } ) ,
36- ] ;
29+ // For 'classic' sessions that are yet to migrate to Workflow Studio, create a SDK token for this applicant
30+ // in your backend and use it here
31+ const sdkToken = '<Your SDK token>' ;
3732
3833// Language keys: https://sdk.onfido.com/capture/i18n/index.json
3934// Custom translations for a module name and a language: https://sdk.onfido.com/capture/i18n/welcome/en_US.min.json
@@ -51,36 +46,47 @@ const customTranslations = {
5146
5247const customTheme : Theme = {
5348 mode : ThemeMode . Light ,
49+ branding : {
50+ text : 'Brand Name' ,
51+ logo : 'https://commons.wikimedia.org/wiki/File:React-icon.svg' , // URL to a publicly accessible SVG image
52+ } ,
5453 lightColors : {
55- backgroundColorOverlay : '#10598A85' , // pass RGBA HEX colors, we internally convert to ARGB
54+ backgroundColorOverlay : '#10598A85' ,
5655 } ,
5756 darkColors : {
58- backgroundColorOverlay : '#10598A85' , // pass RGBA HEX colors, we internally convert to ARGB
57+ backgroundColorOverlay : '#10598A85' ,
5958 } ,
6059} ;
6160
6261const configuration : Configuration = {
63- disableAnalytics : false ,
6462 theme : customTheme ,
6563 localisation : customTranslations ,
6664} ;
6765
66+ const studioFlowParameters : StudioParameters = {
67+ sdkToken : studioToken ,
68+ configuration : configuration ,
69+ } ;
70+
71+ // 'Classic' flow example (unused)
72+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
6873const classicFlowParameters : ClassicParameters = {
69- sdkToken : SDK_TOKEN ,
70- steps : classicSteps ,
74+ sdkToken : sdkToken ,
75+ steps : [ Welcome ( ) , Document ( ) , FaceMotion ( ) ] ,
7176 configuration : configuration ,
7277} ;
7378
7479export default function App ( ) {
75- const isDarkMode = useColorScheme ( ) === 'dark' ;
76-
7780 const handleLaunchSDK = ( ) => {
7881 const callbacks : Callbacks = {
79- onComplete : ( result ) => {
80- console . log ( 'The onComplete callback has been called. Received:' , result ) ;
82+ onComplete : result => {
83+ console . log (
84+ 'The onComplete callback has been called. Received:' ,
85+ result ,
86+ ) ;
8187 // Finish or navigate away
8288 } ,
83- onError : ( error ) => {
89+ onError : error => {
8490 console . error ( 'The onError callback has been called with:' , error ) ;
8591 Alert . alert ( 'An error occurred' , error . message , [
8692 {
@@ -91,36 +97,22 @@ export default function App() {
9197 } ,
9298 ] ) ;
9399 } ,
94- onUserExit : ( userAction ) => {
95- console . log ( 'The onUserExit has been called with userAction:' , userAction ) ;
100+ onUserExit : userAction => {
101+ console . log (
102+ 'The onUserExit has been called with userAction:' ,
103+ userAction ,
104+ ) ;
96105 // Finish or navigate away
97106 } ,
98- onAnalytics : ( event ) => {
99- console . log ( 'The onAnalytics callback has been called with:' , event ) ;
100- } ,
101- onMedia : ( media : MediaResult ) => {
102- console . log ( 'The onMedia callback has been called with:' , media ) ;
103- } ,
104- biometricsTokenHandler : {
105- onTokenGenerated : ( customerUserHash , _encryptedBiometricToken ) => {
106- // Store the token securely (e.g., AsyncStorage, SecureStore)
107- console . log ( 'Token generated for:' , customerUserHash ) ;
108- } ,
109- onTokenRequested : ( customerHash ) => {
110- // Retrieve the token from secure storage
111- console . log ( 'Token requested for:' , customerHash ) ;
112- return '' ; // Return the stored token or empty string
113- } ,
114- } ,
115107 } ;
116108
117109 const idv = new EntrustIdv ( callbacks ) ;
118- idv . start ( classicFlowParameters ) ; // For studio flows, use studioFlowParameters instead
110+ idv . start ( studioFlowParameters ) ;
119111 } ;
120112
121113 return (
122114 < SafeAreaProvider >
123- < StatusBar barStyle = { isDarkMode ? 'light-content' : 'dark-content' } />
115+ < StatusBar />
124116 < SafeAreaView style = { styles . container } >
125117 < View style = { styles . content } >
126118 < Button title = "Launch SDK" onPress = { handleLaunchSDK } />
0 commit comments