videokyc_flutter 1.7.0
videokyc_flutter: ^1.7.0 copied to clipboard
A Flutter SDK for integrating SurePass Video KYC verification.
SurePass Video KYC Flutter SDK #
Drop-in SurePass Video KYC verification for Flutter apps. One call pushes the whole flow — session setup, permissions, and the verification WebView — and returns a typed result.
Requirements #
Flutter >=3.24.0 (Dart >=3.5.0) · Android API 28+ · iOS 15.0+
Installation #
dependencies:
videokyc_flutter: ^1.7.0
Platform setup #
The SDK requests permissions at runtime but cannot declare them for you. Skip this and the requests fail — and on iOS, a missing Info.plist key crashes the app.
Android #
Add to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
Set minSdk = 28 in android/app/build.gradle.kts (or minSdkVersion 28 in android/app/build.gradle on older Groovy projects).
Uploading a photo taken with the camera needs nothing more. When the verification page asks for a file, Android offers the camera next to the file picker. The photo reaches the page through a FileProvider that the SDK declares in its own Android manifest, which merges into your app's when you build. If your app already declares com.pichillilorenzo.flutter_inappwebview_android.InAppWebViewFileProvider itself, remove that declaration or make it match the SDK's exactly: authority ${applicationId}.flutter_inappwebview_android.fileprovider and paths @xml/provider_paths. A declaration that differs fails the manifest merge. If your app has its own res/xml/provider_paths.xml, Android uses it in place of the SDK's, so it must include <external-path name="external_files" path="." />.
If your Android build fails on proguard-android.txt
flutter_inappwebview ^6.1.5 does not build under Android Gradle Plugin 9, the default in recent Flutter. Add this to your app's pubspec.yaml, then run flutter pub get:
dependency_overrides:
flutter_inappwebview: 6.2.0-beta.3
dependency_overrides only takes effect in the root app. Remove it once flutter_inappwebview 6.2.0 ships stable — this SDK's ^6.1.5 constraint picks it up automatically.
iOS #
Add to ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required for video KYC verification.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required for video KYC verification.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location access is required for video KYC verification.</string>
Set the app's minimum iOS version to 15.0. In Xcode, select the Runner target, open General, and set Minimum Deployments to 15.0. This is IPHONEOS_DEPLOYMENT_TARGET in ios/Runner.xcodeproj/project.pbxproj, which Flutter's app template sets to 13.0. Xcode 27 builds only for iOS 15.0 and later, so with 13.0 the build fails with The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 13.0, but the range of supported deployment target versions is 15.0 to 27.0.x.
If your app has an ios/Podfile, set platform :ios, '15.0' there as well, and merge these lines into your existing post_install block (don't add a second block):
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 15.0
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'
end
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
'PERMISSION_CAMERA=1',
'PERMISSION_MICROPHONE=1',
'PERMISSION_LOCATION=1',
]
end
end
end
The IPHONEOS_DEPLOYMENT_TARGET lines raise every pod to 15.0. That includes the Flutter pod, whose generated podspec asks for 13.0 and fails the same way under Xcode 27.
The PERMISSION_* lines matter when permission_handler is built with CocoaPods, which compiles its iOS permissions out by default. Without them, the prompts never appear and the flow ends immediately with VideoKycStatus.error. Recent Flutter versions build it as a Swift package by default instead, and it then turns each permission on from its Info.plist key, so the keys above are all it needs. If you add a key after building once, delete Xcode's DerivedData so it is picked up. An app with no Podfile builds every plugin as a Swift package and can skip this step.
Usage #
import 'package:videokyc_flutter/videokyc_flutter.dart';
final result = await startSurepassVideoKyc(
context: context,
token: 'your_surepass_api_token',
env: Env.sandbox, // or Env.prod
workflowId: 'your_workflow_id',
email: 'user@example.com',
fullName: 'John Doe',
mobileNumber: '9876543210',
userImage: selfieBytes, // optional Uint8List from your own image picker
advanceParameters: const VideoKycAdvanceParameters( // optional thresholds
panLivenessThreshold: 20,
panNameMatchThreshold: 70,
aadhaarLivenessThreshold: 50,
),
onInitialized: (VideoKycModel model) {
debugPrint('User: ${model.userId}, session: ${model.sessionId}');
},
);
switch (result?.status) {
case VideoKycStatus.success:
debugPrint('Completed — session ${result!.sessionId}');
case VideoKycStatus.cancelled:
debugPrint('Cancelled by the user');
case VideoKycStatus.error:
debugPrint('Error: ${result!.errorMessage}');
case VideoKycStatus.failed:
debugPrint('Verification failed: ${result!.errorMessage}');
case null: // dismissed before reaching a terminal status
break;
}
See example/ for a runnable app.
Appearance #
The SDK's screens and dialogs take their colours and type from the host app's Theme, dark mode included, so the flow looks like the rest of your app. There is no separate palette to configure.
Parameters #
| Parameter | Required | Description |
|---|---|---|
context |
✅ | BuildContext used to push the KYC flow. |
token |
✅ | Your SurePass API authentication token. |
env |
✅ | Env.sandbox or Env.prod. |
workflowId |
✅ | Your SurePass workflow id. |
email |
— | User's email address. |
fullName |
— | User's full name. |
mobileNumber |
— | 10-digit mobile number, no country-code prefix. |
userImage |
— | Raw image bytes (Uint8List) from your app's gallery or camera picker, base64-encoded and sent as advance_parameters.user_image. |
advanceParameters |
— | Verification thresholds (VideoKycAdvanceParameters), whole numbers sent in the same advance_parameters object. See Advance parameters. |
onInitialized |
— | Callback receiving the VideoKycModel once the session initializes: userId, workflowId, sessionId, videoKycUrl, plus the optional workflowSessionId, eventType, and signature. Also called when the user continues an unfinished session, with that session's details. |
The create-user API requires email, fullName, and mobileNumber, so omitting one — or passing an empty string — sends a placeholder in its place (vkyc.user@example.com, vkyc user, 1234567890). The flow runs normally, but the KYC record then carries placeholder identity data instead of the customer's own. Pass real values whenever you have them.
Advance parameters #
VideoKycAdvanceParameters holds the verification thresholds, each an optional int:
| Document | Fields |
|---|---|
| PAN | panLivenessThreshold, panNameMatchThreshold |
| Voter ID | voterPanImageThreshold, voterLivenessThreshold, voterNameMatchThreshold, voterPanNameMatchThreshold |
| Aadhaar | aadhaarPanImageThreshold, aadhaarLivenessThreshold, aadhaarPanNameMatchThreshold |
| Driving licence | dlPanImageThreshold, dlCardLivenessThreshold, dlApiLivenessThreshold, dlCardApiLivenessThreshold, dlPanApiImageThreshold, dlNameMatchThreshold, dlPanNameMatchThreshold |
Each field is sent under the snake_case form of its name (panLivenessThreshold → pan_liveness_threshold), in the same advance_parameters object as user_image. Only the thresholds you set are sent, exactly as given; the SDK does not check their range. If your thresholds already arrive as JSON, VideoKycAdvanceParameters.fromJson(map) reads that shape directly. With no image and no thresholds, advance_parameters is left out of the request entirely.
Result #
startSurepassVideoKyc() returns a SurepassVideoKycResult?, or null if the flow is dismissed before reaching a terminal status.
| Field | Description |
|---|---|
status |
success, failed, cancelled, or error. success, failed and cancelled are the server's own verdict on the session; error covers everything that stopped the SDK from getting one — network errors, permission denials, device location turned off, API failures, and a verification the SDK could not follow to its end. |
sessionId |
The session id for tracking, when available. |
errorMessage |
For failed, the server's own reason (its error_safe_description and error_code) when it gave one. For error, the setup or API failure; may be null for in-flow WebView load errors. |
How the outcome is decided #
Once the verification page is open, the SDK polls SurePass for the session's
current_status every 3 seconds and ends the flow when the server reports a
terminal one — COMPLETED, FAILED, or CANCELED. The server is the
authority: nothing in the page itself is trusted to report the outcome, so a
reload, a backgrounded app, or a network that blocks WebSockets cannot lose the
result. Polling pauses while your app is in the background and reads again the
moment it returns.
The verification page sits below a thin strip carrying a back arrow at its
leading edge. The user can leave the flow before it ends — with that arrow, or
the system back button on Android — which asks for confirmation first and then
returns VideoKycStatus.cancelled.
If the session has still not reached a terminal status after 20 minutes, or if
several consecutive reads fail, the flow ends with VideoKycStatus.error rather
than guessing at an outcome. The verification itself may well have succeeded —
treat that status as "ask the server", not as a failure.
Continuing an unfinished verification #
When the user leaves the verification page that way, the SDK keeps the
session. On the next startSurepassVideoKyc call with the same values, it asks
SurePass whether that session is still open, and if it is, asks the user
whether to continue it:
- Continue reopens the same session where the user left it. No new session
is created.
onInitializedis called again with that session's details, and the result carries itssessionId. - Start over creates a new session, exactly as a first call does. The old one is left as it is on the server.
- Closing the question with the back button returns
VideoKycStatus.cancelledand keeps the session for the next call.
The same values means the same env, workflowId, email, fullName,
mobileNumber, userImage and advanceParameters. The token is not
compared, so a refreshed token still finds the session. A call that differs in
anything else starts a new session without asking, because the kept session
was created without that difference and would ignore it.
The session is kept in memory only, for as long as your app's process runs, and nothing is written to the device. Only the session the user last left is kept. A call that ends any other way (completed, failed or an error) leaves nothing to continue. Neither does a session SurePass reports as no longer open. If SurePass can't be reached to check, the user isn't asked and a new session is created.
Permissions #
Camera (video capture), microphone (session audio), and location (location verification) are requested when the flow starts, before the session is created. The in-flow WebView re-requests them on demand if the verification page asks.
Two things beyond the permissions themselves:
- Precise location on Android. A user who allows only approximate location is asked for precise location. iOS can't be held to this — the permission plugin can't tell whether Precise Location is on — so there a user with it off still continues.
- The device's location setting must be on. With it off, the verification page's location check can never finish.
When something is missing, the flow doesn't end outright — the SDK shows a dialog matched to what the user can still do:
- Denied — Try Again asks again.
- Permanently denied, so the OS will not prompt again (Android: a second denial or "Don't ask again"; iOS: a single denial) — Open Settings opens the app's settings page and asks again when the user returns. Changing a permission there can restart the app process, in which case your app resumes at its own entry point.
- Location turned off on the device — Open Settings opens the device's location settings, where that switch lives, and checks again when the user returns. (On iOS it opens the app's page in Settings, the closest iOS allows.)
- Restricted by device policy or parental controls — explained, with no action to offer.
Cancelling that dialog ends the flow with VideoKycStatus.error and an errorMessage naming what was missing: the permissions not granted, or Location is turned off on this device.
Avoid requesting other permissions while the flow is starting. If a permission request fails — two requests at once is the usual cause — the flow ends with VideoKycStatus.error and an errorMessage starting Could not request permissions:.
License #
Released under the MIT License — see LICENSE for details.