Kalapa NFC Reader SDK for Flutter
A Flutter plugin for integrating Kalapa's NFC Reader SDK, enabling NFC reading functionality for identity documents in Flutter applications.
Features
- Check NFC support and status
- Read NFC data from identity documents
- UI and non-UI reading modes
- Customizable SDK appearance
- Support for both iOS and Android platforms
Installation
Add this to your package's pubspec.yaml file:
dependencies:
kalapa_nfc_reader_sdk: ^1.0.3
Platform Setup
Android
Add the following permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="false" />
iOS
Add the following to your Info.plist:
<key>NFCReaderUsageDescription</key>
<string>App needs NFC Scan Usage</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
<string>A0000002472001</string>
<string>00000000000000</string>
</array>
<key>NSCameraUsageDescription</key>
<string>App will use your camera to take a photo.</string>
Usage
Import the package
import 'package:kalapa_nfc_reader_sdk/kalapa_nfc_reader_sdk.dart';
Initialize the SDK
final _kalapaNfcReaderSdk = KalapaNfcReaderSdk();
Configure the SDK
await _kalapaNfcReaderSdk.configureSDK(
backgroundColor: "#FFFFFF",
mainColor: "#62A583",
textColor: "#65657B",
btnTextColor: "#FFFFFF",
language: "vi",
customer: "",
regularFont: "",
mediumFont: "",
boldFont: "",
);
Check NFC Support
bool isSupported = await _kalapaNfcReaderSdk.isNFCSupported();
bool isEnabled = await _kalapaNfcReaderSdk.isNFCEnabled();
Start NFC Reading with UI
try {
String result = await _kalapaNfcReaderSdk.startWithUI();
print('NFC Data: $result');
} catch (e) {
print('Error: $e');
}
Start NFC Reading without UI
String mrz = "Your MRZ data here";
try {
String result = await _kalapaNfcReaderSdk.startWithoutUI(mrz);
print('NFC Data: $result');
} catch (e) {
print('Error: $e');
}
Get SDK Version
String version = await _kalapaNfcReaderSdk.getSDKVersion();
API Reference
Methods
| Method | Parameters | Return Type | Description |
|---|---|---|---|
configureSDK |
backgroundColor, mainColor, textColor, btnTextColor, language, customer, regularFont, mediumFont, boldFont | Future<bool> |
Configure SDK appearance and settings |
isNFCSupported |
- | Future<bool> |
Check if device supports NFC |
isNFCEnabled |
- | Future<bool> |
Check if NFC is enabled |
startWithUI |
- | Future<String> |
Start NFC reading with built-in UI |
startWithoutUI |
mrz (String) | Future<String> |
Start NFC reading without UI using MRZ data |
getSDKVersion |
- | Future<String> |
Get SDK version |
Configuration Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
backgroundColor |
String | "#FFFFFF" | Background color in hex format |
mainColor |
String | "#62A583" | Main theme color in hex format |
textColor |
String | "#65657B" | Text color in hex format |
btnTextColor |
String | "#FFFFFF" | Button text color in hex format |
language |
String | "vi" | Language code ("vi" or "en") |
customer |
String | "" | Customer identifier |
regularFont |
String | "" | Regular font name |
mediumFont |
String | "" | Medium font name |
boldFont |
String | "" | Bold font name |
Example
See the example directory for a complete sample app.
License
Copyright © 2024 Kalapa. All rights reserved.