Skip to main content

Integration

For IOS Devices

Update Podfile

Set the global platform of your project to iOS 13.0

platform :ios, '13.0'

Add the SDK’s source to your podfile.

source "https://github.com/AmaniTechnologiesLtd/Mobile_SDK_Repo"
source "https://github.com/CocoaPods/Specs"

Add the section below to your post-install hook

target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end

Final result should look like this

post_install do |installer|
xcode_base_version = xcodebuild -version | grep 'Xcode' | awk '{print $2}' | cut -d . -f 1

installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
# This block is for xcode 15
if config.base_configuration_reference && Integer(xcode_base_version) >= 15
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
end
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
if target.name == 'AmaniSDK'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end
if target.name == 'AmaniUI'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
end
end
end
end
end

Building for devices that don’t support NFC

For not NFC supported device (like iPhone 6) there is no CoreNFC library in system and also we are using some ios crypto libraries for reading nfc data supported after iOS 13. You need to add below listed libraries as optional under Build Phases->Link Binary With Libraries menu. Even if you don't use the nfc process, you should add.

CoreNFC.framework
CryptoTokenKit.framework
CryptoKit.framework

For Android Devices

Android Gradle changes

Add jitpack and our artifact repository to the repositories section of your gradle file

maven { url 'https://www.jitpack.io' }
maven {
url = "https://jfrog.amani.ai/artifactory/amani-sdk"
}

On your module’s build.gradle file under the android/app/build.gralde add the changes below inside of android section.

packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
}
dataBinding { enabled true }

aaptOptions {
noCompress "tflite"
}

On the same file, update your minSdkVersion to 21 or later.

defaultConfig {
applicationId "ai.amani.flutterexample"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}

Update your AndroidManifest.xml

You must add tools:replace="android:label, android:name" on your main android manifest 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">

Change MainActivity to extend FlutterFragmentActivity

Some features of this SDK uses methods from FlutterFragmentActivity. To use this SDK you must extend your main activity with FlutterFragmentActivity insead of FlutterActivity

import io.flutter.embedding.android.FlutterFragmentActivity;
public class MainActivity extends FlutterFragmentActivity {

}

ProGuard Rule Usage

  • If you are using ProGuard in your application, you just need to add this lines into your ProGuard Rules!
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-keep class io.flutter.plugin.editing.** { *; }
-keep class ai.amani.amanisdk.AmanisdkPlugin {*;}
-dontwarn ai.amani.amanisdk.AmanisdkPlugin

-keep class ai.** {*;}
-dontwarn ai.**
-keep class datamanager.** {*;}
-dontwarn datamanager.**
-keep class networkmanager.** {*;}
-dontwarn networkmanager.**
-keep class ai.amani.jniLibrary.CroppedResult.**{*;}

-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**