@surepass/digilocker-react-native-sdk
v1.0.0
Published
React Native wrapper for Digilocker SDK (Android .aar + iOS .xcframework)
Readme
Digilocker React Native SDK
React Native wrapper for the Digilocker SDK — enables Aadhaar-based identity verification on Android and iOS via SurePass.
Features
- Single JS API (
launchSDK) for both platforms - Android: prebuilt
.aarbinary, auto-linked via React Native config - iOS: prebuilt
.xcframework, linked via CocoaPods - TypeScript definitions included
- Promise-based with typed results and error codes
Requirements
| Requirement | Minimum | | ----------------- | -------------- | | React Native | 0.70+ | | iOS | 15.0 | | Android minSdk | 28 | | Android compileSdk| 34 | | Swift | 5.7 | | Kotlin / Java | 1.8 / 17 |
Installation
npm install @surepass/digilocker-react-native-sdk
# or
yarn add @surepass/digilocker-react-native-sdkiOS
cd ios && pod installAndroid
No additional setup needed — the module is auto-linked.
Quick Start
import { launchSDK } from '@surepass/digilocker-react-native-sdk';
try {
const result = await launchSDK('<your-token>', 'PREPROD');
if (result.success) {
// iOS → result.clientId
// Android → result.signedResponse, result.status_code
console.log('Verified!', result.clientId ?? result.signedResponse);
} else {
console.warn('Verification failed:', result.error);
}
} catch (e: any) {
switch (e.code) {
case 'USER_CANCELLED':
console.log('User backed out (Android)');
break;
case 'SDK_ERROR':
console.log('SDK error (iOS):', e.message);
break;
default:
console.error('Unexpected error:', e);
}
}Token: Obtain a bearer token from the Digilocker Initialize API before calling
launchSDK.
API Reference
launchSDK(token, env)
Launches the Digilocker verification flow.
| Parameter | Type | Description |
| --------- | ------------- | -------------------------------------------- |
| token | string | Bearer token from the Initialize API |
| env | Environment | 'PREPROD' (sandbox) or 'PROD' (live) |
Returns: Promise<SDKResult>
SDKResult
| Field | Type | Platform | Description |
| ---------------- | --------- | -------- | ------------------------------------------------ |
| success | boolean | Both | Whether the verification completed successfully |
| clientId | string? | iOS | Client ID for the Download Aadhaar API |
| signedResponse | string? | Android | Raw signed JSON string from the SDK |
| status_code | number? | Android | HTTP-style status code from the SDK response |
| error | string? | Both | Error message when success is false |
Error Codes
| Code | Platform | Description |
| --------------------- | -------- | ---------------------------------------- |
| USER_CANCELLED | Android | User pressed back / cancelled the flow |
| SDK_BUSY | Android | Another SDK session is already running |
| NO_ACTIVITY | Android | No current activity available |
| LAUNCH_ERROR | Android | Failed to start the SDK activity |
| PARSE_ERROR | Android | SDK returned a response that could not be parsed as JSON |
| UNKNOWN_RESULT | Android | SDK returned an unrecognised result code |
| SDK_ERROR | iOS | SDK returned a failure or was cancelled |
| NO_VIEW_CONTROLLER | iOS | Could not find a root view controller |
Troubleshooting
The package '@surepass/digilocker-react-native-sdk' doesn't seem to be linked
Rebuild the app after installing:
# iOS
cd ios && pod install && cd ..
npx react-native run-ios
# Android
npx react-native run-androidiOS build fails with missing framework
Ensure ios/DigilockerSDK.xcframework is present in the package and that pod install completed without errors.
Android build fails with missing .aar
Verify android/libs/app-release.aar exists in the package directory.
