prembly_kyc 0.1.2+3
prembly_kyc: ^0.1.2+3 copied to clipboard
A Flutter widget for Prembly/IdentityPass KYC verification. Presents a draggable bottom sheet with an embedded WebView for seamless identity verification.
Prembly Kyc #
A Flutter widget for Prembly/IdentityPass KYC verification. Presents a beautiful, Intercom-style draggable bottom sheet with an embedded WebView for seamless identity verification.
Features #
- Automatic camera permission handling
- Clean callback API for success, error, and cancellation
- Automatic widget initialization via Prembly API
- iOS and Android support
Installation #
Add prembly_kyc to your pubspec.yaml:
dependencies:
prembly_kyc: ^0.1.0
Then run:
flutter pub get
Platform Configuration #
Android #
Add the following permissions to your android/app/src/main/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
</manifest>
iOS #
Add the following to your ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required for identity verification</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app may requires access to your location to complete verification</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Allow access to your phone's location for verification</string>
Prerequisites #
Before using this package, you need to:
- Create an account on Prembly Dashboard
- Create a widget and get your
widgetIdandwidgetKey
Usage #
Basic Usage #
import 'package:prembly_kyc/prembly_kyc.dart';
// In your widget
ElevatedButton(
onPressed: () async {
await PremblyKyc(
config: PremblyConfig(
widgetId: 'your_widget_id',
widgetKey: 'wdgt_your_widget_key',
email: 'user@example.com',
firstName: 'John',
lastName: 'Doe',
),
onSuccess: (response) {
print('Verified via ${response.channel}');
print('Data: ${response.data}');
},
onError: (error) {
print('Error: ${error.message}');
if (error.isPermissionError) {
// Show permission settings dialog
}
},
onClose: () {
print('Widget closed');
},
).show(context);
},
child: Text('Verify Identity'),
)
With Extra Metadata #
You can include additional metadata with the verification:
PremblyKyc(
config: PremblyConfig(
widgetId: 'your_widget_id',
widgetKey: 'wdgt_your_widget_key',
firstName: 'John',
lastName: 'Doe',
email: 'user@example.com',
metadata: {
'user_id': 'user_123',
'source': 'mobile_app',
'custom_field': 'your_value',
},
),
// ...callbacks
).show(context);
API Reference #
PremblyConfig #
| Property | Type | Required | Description |
|---|---|---|---|
widgetId |
String |
Yes | Your Prembly widget ID |
widgetKey |
String |
Yes | Your Prembly widget key (format: wdgt_xxx...) |
email |
String |
Yes | User's email address |
firstName |
String |
Yes | User's first name |
lastName |
String |
Yes | User's last name |
metadata |
Map<String, dynamic>? |
No | Additional data to include |
PremblyResponse #
Returned on successful verification:
| Property | Type | Description |
|---|---|---|
status |
String |
"success" |
code |
String |
"00" for success |
message |
String |
Success message |
channel |
String |
Verification type (e.g., "BVN", "NIN") |
data |
Map<String, dynamic>? |
Verification data |
PremblyError #
Returned on errors:
| Property | Type | Description |
|---|---|---|
type |
PremblyErrorType |
Type of error |
message |
String |
Error message |
code |
String? |
Error code (e.g., "E01", "E02") |
isCancelled |
bool |
Whether user cancelled |
isPermissionError |
bool |
Whether it's a permission issue |
Error Types #
enum PremblyErrorType {
cameraPermissionDenied,
cameraPermissionPermanentlyDenied,
locationPermissionDenied,
initializationFailed,
cancelled,
verificationFailed,
networkError,
webViewError,
unknown,
}
How It Works #
- Permission Check: Requests camera and location permission if not already granted
- Display: Shows a modal bottom sheet with the Prembly verification UI
- Verification: User completes the verification flow
- Callback: Returns the result via
onSuccessoronErrorcallbacks
Closing the Widget #
Users can close the verification widget via:
- The X button in the Prembly widget (if redirect URL is configured in dashboard)
- Dragging down on the handle
- The "Cancel" button at the bottom
- System back button/gesture
Webhook Integration #
For production use, configure your webhook URL in the Prembly dashboard to receive verification results on your backend. This ensures you have a server-side record of all verifications.
Contributing #
Contributions are welcome!
Credits #
Built with ❤️ by Mubharaq