Introduction
This is the documentation for our Flutter bindings for Amani eKYC platform SDK.
On the example folder at our repository you can find a close to real world solution on how to use this SDK.
Preparation
To setup this SDK correcty, you must complete the steps below
Requirements
The minimum requirements for this SDK are:
- iOS 13.0 or higher
- XCode 14 or higher
- Android API 21 or higher
Installation
Adding the flutter plugin
To add this flutter plugin you must add the lines below to your pubspec.yaml
file.
flutter_amanisdk:
git:
url: https://github.com/AmaniTechnologiesLtd/Flutter_v2
ref: 'feat/v3'
For Android devices
Add your artifact repository to the repositories section of your projects gradle file.
rootProject.allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jfrog.amani.ai/artifactory/amani-sdk" }
jcenter()
}
}
On the module's gradle file, add our native android SDK to the dependencies
dependencies {
implementation 'ai.amani.android:AmaniAi:3.0.4'
}
On the same file, add this block to the android
section
aaptOptions {
noCompress "tflife"
}
Android Proguard Rules
Add this into your proguard-rules.pro
-keep class ai.amani.flutter_amanisdk_v2
-keep class ai.** {*;}
-dontwarn ai.**
-keep class datamanager.** {*;}
-dontwarn datamanager.**
-keep class networkmanager.** {*;}
-dontwarn networkmanager.**
-keep class org.jmrtd.** {*;}
-keep class net.sf.scuba.** {*;}
-keep class org.bouncycastle.** {*;}
-keep class org.spongycastle.** {*;}
-keep class org.ejbca.** {*;}
-dontwarn org.ejbca.**
-dontwarn org.bouncycastle.**
-dontwarn org.spongycastle.**
-dontwarn org.jmrtd.**
-dontwarn net.sf.scuba.**
-keep class org.tensorflow.lite**{ *; }
-dontwarn org.tensorflow.lite.**
-keep class org.tensorflow.lite.support**{ *; }
-dontwarn org.tensorflow.lite.support**
Changing the MainActivity type
For this Flutter Plugin to work, you must change your MainActivity
class to implement FlutterFragmentActivity
.
This change is required otherwise you'll have runtime issues
Example Mainactivity.ky
package ai.amani.flutter_amanisdk_example
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity() {}
Update your AndroidManifest.xml
You must add tools:replace="android:label, android:name"
on your main AndroidManifest.xml
file.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" # this line must be added
package="ai.amani.amanisdk_example">
<application
android:label="amanisdk_example"
android:name="${applicationName}"
tools:replace="android:label, android:name" #this line must be added
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
tools:replace="android:theme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
For iOS devices
Add these lines on your Podfile
\
source "https://github.com/AmaniTechnologiesLtd/Mobile_SDK_Repo"
source "https://github.com/CocoaPods/Specs"
If not yet set the default iOS version to 13
platform :ios, '13.0'
iOS Permission
iOS permissions
You have to add these permissions into your info.plist
file. The permissions below must be added according to your usage and you're required to add these permissions for app submission.
For NFC:
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
</array>
<key>NFCReaderUsageDescription</key>
<string>This application requires access to NFC to scan IDs.</string>
For Location:
<key>NSLocationWhenInUseUsageDescription</key>
<string>This application requires access to your location to upload the document.</string>
<key>NSLocationUsageDescription</key>
<string>This application requires access to your location to upload the document.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This application requires access to your location to upload the document.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This application requires access to your location to upload the document.</string>
For Camera:
<key>NSCameraUsageDescription</key>
<string>This application requires access to your camera for scanning and uploading the document.</string>
Note: You need to add all keys according to your usage.
Grant access to NFC
Grant access to NFC
Enable the Near Field Communication Tag Reading capability in the target Signing & Capabilities.
Building for devices that don’t support NFC
For the devices that don’t support NFC (like iPhone 6), there is no CoreNFC library in the system and we are also using some iOS crypto libraries for reading NFC data supported after iOS 13. You need to add libraries below as optional under the Build Phases->Link Binary With Libraries menu. Even if you don't use the NFC process, you should add this libraries below.
CoreNFC.framework
CryptoKit.framework
CryptoTokenKit.framework