React Native SDK Guide

The prembly-react-native-kyc package provides native UI components and modal workflows for integrating identity verification, document scanning, and face liveness checks directly into iOS and Android applications.


Requirements

React Native0.76 or later, with the New Architecture (the default from 0.76)
iOS15.1 or later
Android7.0 or later (API 24)
ExpoA development build or prebuild. Expo Go is not supported, because the package contains native code.
Peer dependenciesreact, react-native, react-native-webview 13 or later

Installation

Install the main SDK package alongside its peer dependency react-native-webview:

npm install prembly-react-native-kyc react-native-webview
# or
yarn add prembly-react-native-kyc react-native-webview

For iOS builds, install CocoaPods dependencies:

cd ios && pod install && cd ..

Then rebuild the native app. With Expo, run npx expo run:ios or npx expo run:android, or use an EAS development build. There is no config plugin to add.

Upgrading from 1.x

The widget props are unchanged. Version 2 adds native code, so you need pod install, a native rebuild, and React Native 0.76 or later with the New Architecture. Expo Go no longer works.


Native Camera Permissions Setup

Identity verification and liveness challenges use the device camera and microphone, so declare both in your native configuration files.

iOS Configuration (Info.plist)

Add both keys to your ios/YourAppName/Info.plist:

<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera to verify your identity documents and face liveness.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app requires access to the microphone for liveness checks.</string>

Android Configuration (android/app/src/main/AndroidManifest.xml)

Add these permissions to android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />

Android Runtime Permissions (API Level 23+)

On Android devices running API level 23 or higher, ensure your application requests runtime camera permission before launching the SDK modal.

The package itself adds two Android permissions that show no prompt: ACCESS_NETWORK_STATE and DETECT_SCREEN_RECORDING (Android 15 and later). It also declares a short, fixed list of packages under <queries> to detect remote-access apps and root managers. Google Play asks you to justify package visibility; the reason is fraud prevention.


Basic Implementation (PremblyIdentityWidget)

Use the <PremblyIdentityWidget /> component to render the verification flow in a native webview modal:

import React, { useState } from 'react';
import { Button, View, StyleSheet, Text } from 'react-native';
import { PremblyIdentityWidget } from 'prembly-react-native-kyc';

export default function IdentityScreen() {
  const [visible, setVisible] = useState(false);
  const [status, setStatus] = useState<string | null>(null);

  return (
    <View style={styles.container}>
      <Button title="Start Identity Verification" onPress={() => setVisible(true)} />
      
      {status && <Text style={styles.statusText}>Result: {status}</Text>}

      <PremblyIdentityWidget
        isVisible={visible}
        widgetKey="your_public_widget_key_here"
        widgetId="your_widget_id_here"
        firstName="John"
        lastName="Doe"
        email="john@example.com"
        phone="+2348012345678"
        metadata={{
          user_id: 'usr_123456',
          app_version: '1.0.0'
        }}
        callback={(response) => {
          console.log('React Native Callback:', response);
          setStatus(response.status);
          
          if (
            response.status === 'success' ||
            response.status === 'closed' ||
            response.status === 'error_display_closed'
          ) {
            setVisible(false);
          }
        }}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20 },
  statusText: { marginTop: 20, fontSize: 16, fontWeight: 'bold' }
});

Component Props Reference

Prop NameTypeRequiredDescription
isVisibleBooleanYesControls the visibility of the native verification modal wrapper.
widgetKeyStringYesYour public Widget key from SDK Setup in the dashboard.
widgetIdStringYesYour Widget ID from SDK Setup in the dashboard.
firstNameStringYesThe user's first name.
lastNameStringYesThe user's last name.
emailStringYesThe user's email address.
phoneStringNoThe user's phone number.
metadataObjectNoCustom JSON object passed back in verification callbacks & webhooks.
collectDeviceDataBooleanNoDefaults to true. Reads the phone's own device ID and details and passes them to the widget, so device checks see the real device. No permission prompt is shown and location is never read. Set to false to use only what the web page can see.
callbackFunctionYesReceives an object with a status key. See Callback statuses.

TypeScript accepts the widget without firstName, lastName and email, but Prembly rejects a session without them: the callback receives api_error.

Callback statuses

The widget never closes itself. Set isVisible to false when you receive a status that ends the flow.

statusWhenOther keys
successVerification finished.data: the session payload.
closedThe user closed the flow.—
errorThe widget reported an error, or its message could not be read.message
api_errorPrembly rejected the session, for example a missing field or a wrong key or ID. The widget shows the error with Retry and Cancel.message
network_errorThe session request could not reach Prembly. The widget shows the error with Retry and Cancel.message
error_display_closedThe user pressed Cancel on that error screen.—
unknown_payloadThe widget sent a message with no event name.data

Any other event the widget reports arrives with its own name as status, plus data, and the flow stays open.

Don't update your records from callback alone. Use webhooks as the source of truth.

To skip the ID screen with a known BVN or NIN, use the PremblyWorkflow component (2.0.2 or later), which takes a prefill prop. See Prefill an ID number.


Face Liveness Biometric Challenge

To require biometric face verification against a stored user photo or reference document image, turn on Face comparison in the widget's settings in the dashboard, then pass the compare_image property inside your metadata object. Without the Face comparison setting, compare_image is ignored.

<PremblyIdentityWidget
  isVisible={visible}
  widgetKey="your_public_widget_key_here"
  widgetId="your_widget_id_here"
  firstName="John"
  lastName="Doe"
  email="john@example.com"
  metadata={{
    user_id: 'usr_123',
    compare_image: 'https://your-server.com/path-to-reference-image.jpg' // Or Base64 string
  }}
  callback={(response) => {
    console.log('Verification result:', response.status);
    if (['success', 'closed', 'error_display_closed'].includes(response.status)) {
      setVisible(false);
    }
  }}
/>

Troubleshooting (React Native)

  • Blank White Screen in Modal: Ensure react-native-webview is correctly installed and native project files were rebuilt (npx react-native run-android / npx react-native run-ios).
  • Camera Fails to Open: Check native logs (adb logcat or Xcode Console) to ensure NSCameraUsageDescription and android.permission.CAMERA are configured.
  • Native module errors at startup, or nothing happens in Expo Go: Version 2 contains native code. Rebuild the native app after installing, make sure the New Architecture is on (React Native 0.76 or later), and use an Expo development build instead of Expo Go.