React Native SDK v1 Integration

Looking for v2?

If your Template starts with tmpl_, you’re on v1.

We will stop making updates to v1 on December 31, 2022. You will still be able to create inquiries, but no new features or fixes will be available. We recommend moving to v2 for access to the latest product improvements- please see migration to v2 section or contact us.

Cocoapods 1.9.3 is incompatible

Cocoapods 1.9.3 has a bug that prevents builds from selecting the correct architecture. See more details here: https://github.com/CocoaPods/CocoaPods/pull/9790.

To install, please downgrade to 1.8.x or upgrade to 1.10.x

Installation

Inquiry SDK latest To install the Persona React Native SDK within your React Native application, if you use yarn to manage your project dependencies

yarn add react-native-persona

If you use npm to manage your project dependencies

npm i react-native-persona

Configure Android

Add Maven repository

Open your android/build.gradle file. Add the Persona Maven repository to the bottom of your repository list.

allprojects {
repositories {
// ...
maven {
url 'https://sdk.withpersona.com/android/releases'
}
}
}

Make sure minimum compile is over 30

In the app/build.gradle file, make sure the compileSdkVersion is at least 31.

android {
// ...
compileSdkVersion = 31
// ...
}

If you change the targetSdkVersion to be above 30 as well, you’ll need to set android:exported="true" on your Activity in the AndroidManifest.xml file.

Configure iOS

Install iOS pods

cd ios; pod install

Enable iOS Permissions

Ensure access to the Camera within your iOS app.

Modify your Info.plist:

Navigate to your project’s settings in Xcode and click the Info tab Add a new Privacy - Camera Usage Description entry (if not already present) to enable camera access.

Set iOS minimum deployment target

Our native iOS SDK requires a minimum iOS deployment target of 11.0.

In your project’s ios/Podfile, ensure your platform target is set to 11.0.

platform :ios '11.0'

iOS frameworks support

Recent versions of React Native project generators should have this included by default. If you have been incrementally updating your React Native project from older versions, however, you may need to add this.

Without use_frameworks! the SDK will fail to compile due to problems importing Lottie, which is a dependency of the SDK.

Usage

The Persona Inquiry flow can be initiated with either a template ID or an inquiry ID.

Please refer to the code sample below and replace my_template_id with your template ID. You can find your template ID on the Persona Dashboard under Integration.

This starts the Inquiry flow and takes control of the user interface. Once the flow completes, the control of the user interface is returned to the app and the appropriate callbacks are called.

typescript
1import Inquiry, {Environment} from 'react-native-persona';
2// ...
3<Button
4 title="Start Inquiry"
5 onPress={() => {
6 Inquiry.fromTemplate('tmpl_JAZjHuAT738Q63BdgCuEJQre')
7 .environment(Environment.SANDBOX)
8 .onSuccess((inquiryId, attributes) =>
9 Alert.alert('Success', `Inquiry ${inquiryId} succeeded`,),
10 )
11 .onCancelled(() =>
12 Alert.alert('Canceled', 'Inquiry was cancelled'),
13 )
14 .onFailed(inquiryId =>
15 Alert.alert('Failed', `Inquiry ID: ${inquiryId}`),
16 )
17 .onError(error => Alert.alert('Error', error.message))
18 .build()
19 .start();
20 }}
21/>

Inquiry Attributes

The onSuccess callback returns attributes, which is an object containing information extracted during the inquiry. The attributes object includes birthdate, name, and address.

Configuration options

Some different configuration example can be found below

javascript
1// Configuration with only a template ID
2Inquiry.fromTemplate("tmpl_JAZjHuAT738Q63BdgCuEJQre").build().start();
3
4// Configuration with only a template ID in the sandbox
5Inquiry.fromTemplate("tmpl_JAZjHuAT738Q63BdgCuEJQre")
6 .environment(Environment.SANDBOX)
7
8// Configuration with a template and reference ID
9Inquiry.fromTemplate("tmpl_JAZjHuAT738Q63BdgCuEJQre")
10 .referenceId("myReference")
11 .build()
12 .start();
13
14// Configuration with a template and account ID
15Inquiry.fromTemplate("tmpl_JAZjHuAT738Q63BdgCuEJQre")
16 .accountId("act_W6thEnEU19gphPqq5uTzZ4Y8")
17 .build()
18 .start();
19
20// Configuration with only an inquiry ID
21Inquiry.fromInquiry("inq_JAZjHuAT738Q63BdgCuEJQre").build().start();
22
23// Configuration resuming an inquiry session with an access token
24Inquiry.fromInquiry("inq_JAZjHuAT738Q63BdgCuEJQre")
25 .accessToken("SOME_SESSION_TOKEN")
26 .build()
27 .start();

Theming

In order to theme the experience, use the persona-tool to customize the colors of Persona Inquiry flow. The tool itself acts as a guide to walk you through theming your experience.

sh
1# yarn
2yarn persona-tool
3
4# npm
5npx persona-tool

Follow the instructions provided by the theming tool to set up the proper configuration. Themes will need to be configured separately for iOS and Android.

For more information on theming, view React Native SDK Theming

Replacing strings

You can replace title, body, or button text by overwriting string resource files.

Replacing strings on Android

React Native strings files are typically located in android/app/src/main/res/values/strings.xml or android/app/src/main/res/values-<LANGUAGE>/strings.xml. Any strings you write will replaces those used by the Persona SDK.

Example:

xml
1<resources>
2 <!-- some of your strings.xml strings -->
3 <string name="persona_inquiry_start_title">This is the start screen title.</string>
4 <string name="persona_inquiry_start_body">This is below that in the body.</string>
5 <string name="persona_inquiry_start_button">I\'m a button!</string>
6 <!-- more of your strings.xml strings -->
7</resources>

Available Android String Keys

  • persona_contact_support_body
  • persona_contact_support_button
  • persona_contact_support_title
  • persona_countryselect_body
  • persona_countryselect_button
  • persona_countryselect_title
  • persona_governmentid_failed_title
  • persona_governmentid_start_body
  • persona_governmentid_start_title
  • persona_governmentid_submitting_body
  • persona_governmentid_submitting_title
  • persona_inquiry_complete_body
  • persona_inquiry_complete_button
  • persona_inquiry_complete_title
  • persona_inquiry_failed_body
  • persona_inquiry_failed_button
  • persona_inquiry_failed_title
  • persona_inquiry_start_body
  • persona_inquiry_start_button
  • persona_inquiry_start_title
  • persona_selfie_failed_body
  • persona_selfie_failed_button
  • persona_selfie_failed_title
  • persona_selfie_start_body
  • persona_selfie_start_button
  • persona_selfie_start_title
  • persona_selfie_submitting_body
  • persona_selfie_submitting_title

Replacing strings on iOS

Provide a Persona.strings file that replaces strings used by the Persona SDK.

Example:

swift
1/*
2 Persona.strings
3*/
4
5"inquiryStartTitle" = "Verify your identity";
6"inquiryStartBody" = "Let’s make sure you’re you!";
7"inquiryStartButton" = "Get started";

Available iOS String Keys

swift
1// Government ID
2"governmentIdFailedTitle" = "Couldn’t verify photos";
3"governmentIdFailedGenericReason" = "Make sure the ID details are clear to read.";
4"governmentIdFailedButton" = "Retry";
5"governmentIdStartTitle" = "Upload a photo ID";
6"governmentIdStartBody" = "We require a photo of a government ID to verify your identity.";
7"governmentIdSubmittingTitle" = "Processing ID";
8"governmentIdSubmittingBody" = "This may take a few seconds";
9"governmentIdChooseType" = "Choose 1 of the following options";
10
11// Taking Government ID photos
12"takeGovIdPhotoHint" = "Take a clear photo of the ID";
13"takeGovIdRetakePhotoButtonText" = "Retake";
14"takeGovIdReviewBackPhoto" = "Review the back of ID";
15"takeGovIdReviewFrontOrBackPhoto" = "Review the ID";
16"takeGovIdReviewFrontPhoto" = "Review the front of ID";
17"takeGovIdUsePhotoButtonText" = "Looks good";
18"takeGovIdReviewPhotoHint" = "Ensure lighting is good and lettering is clear";
19"takeGovIdBackPhotoFormat" = "Back of %@";
20"takeGovIdFrontPhotoFormat" = "Front of %@";
21"takeGovIdGuideHintBackFormat" = "Position the back of the %@ in the frame";
22"takeGovIdGuideHintFrontFormat" = "Position the front of the %@ in the frame";
23
24// Selfie
25"selfieFailedTitle" = "Something went wrong";
26"selfieFailedBody" = "Make sure your face is visible, well lit, and try again.";
27"selfieFailedButton" = "Retry";
28"selfieStartTitle" = "Take a selfie";
29"selfieStartBody" = "Let’s make sure you’re you";
30"selfieStartButton" = "Get started";
31"selfieSubmittingTitle" = "Processing selfie";
32"selfieSubmittingBody" = "This may take a few seconds";
33"takeSelfieCenterPhoto" = "Center yourself in the frame.";
34"takeSelfieLeftPhoto" = "Look slightly left.";
35"takeSelfieRightPhoto" = "Look slightly right.";
36
37// Country selection
38"countrySelectTitle" = "What country is your government ID from?";
39"countrySelectBody" = "This helps us determine the best way to verify your identity.";
40"countrySelectButton" = "Select country";
41"countrySelectPickerText" = "Country of government ID";
42
43// Country List
44"countryListAllCountries" = "ALL COUNTRIES";
45"countryListSuggested" = "SUGGESTED";
46"countryListTitle" = "Select country of ID";
47
48// Inquiry Complete
49"inquiryCompleteTitle" = "Congratulations, you’re done!";
50"inquiryCompleteBody" = "Thanks for verifying your identity.";
51"inquiryCompleteButton" = "Done";
52
53// Inquiry Failed
54"inquiryFailedTitle" = "Could not verify your identity";
55"inquiryFailedBody" = "We were unable to verify your identity.";
56"inquiryFailedButton" = "Close";
57
58// Inquiry Start
59"inquiryStartTitle" = "Verify your identity";
60"inquiryStartBody" = "Let’s make sure you’re you";
61"inquiryStartButton" = "Get started";
62
63// Database
64"databaseStartTitle" = "Just the basics";
65"databaseStartBody" = "Nothing fancy, just a few things to verify your identity.";
66"databaseStartButton" = "Continue";