Flutter plugin installation
Prerequisites
Your existing Flutter application project has to meet the following prerequisites:
- iOS 12 or later
- Xcode 15.2, including Swift 5.9.2 or later
- Android 7 or later, with API level 24
- Android 10 or later, with API level 29, for the biometric authenticator to work
- Android 11 or later, with API level 30, for the device passcode authenticator to work
- Gradle 7.4 or later
- Android Gradle Plugin
com.android.tools.build:gradle
7.2.2 or later - Kotlin Gradle Plugin
org.jetbrains.kotlin:kotlin-gradle-plugin
1.8.0 or later - Dart SDK 3.3.0 or later
- OpenJDK 11 or 17
Due to the privacy information requirement from Apple make sure to use Flutter SDK version 3.19 or newer as only this version contains the privacy manifest. If you still get privacy API usage reports from Apple using this version check your other dependencies.
Pub
Pub is the package manager for the Dart programming language, containing reusable libraries & packages for Flutter and general Dart programs.
Integration with Flutter
To integrate Nevis Mobile Authentication SDK Flutter plugin into your Flutter project with Flutter execute this command:
flutter pub add nevis_mobile_authentication_sdk
This will add a line like this to your package's pubspec.yaml
(and run an implicit flutter pub get
):
dependencies:
nevis_mobile_authentication_sdk: ^3.8.0
Manual integration
Alternatively, you can edit your pubspec.yaml
file manually:
dependencies:
flutter:
sdk: flutter
...
nevis_mobile_authentication_sdk: ^3.8.0
Then open a terminal and update the dependencies.
flutter pub get
Platform specific installation notes
Android
To install Nevis Mobile Authentication Android SDK into your application follow the instructions of Android installation guide, the steps written have to be applied to the Android application part of your Flutter project (e.g.: YOUR_FLUTTER_PROJECT_PATH/android
).
After the basic Android installation follow next chapters for Flutter specific instructions.
Gradle properties configuration
Add the following to your android/gradle.properties
file depending on the Android Gradle Plugin (AGP) version you use:
- AGP 8.3.x or later
- AGP 8.2.x or before
android.useAndroidX=true
android.useFullClasspathForDexingTransform=true
shrink=false
android.useAndroidX=true
android.enableDexingArtifactTransform=false
shrink=false
Dependency configuration
Declare Nevis Mobile Authentication Client SDK as a dependency in your android/app/build.gradle
file. For Flutter projects it is strongly recommended to declare these dependencies using dynamic versions.
dependencies {
//noinspection GradleDynamicVersion
debugImplementation 'ch.nevis:nevis-mobile-authentication-sdk-android-debug:3.8.+'
//noinspection GradleDynamicVersion
releaseImplementation 'ch.nevis:nevis-mobile-authentication-sdk-android:3.8.+'
}
Add release testing workaround
There is an issue with the current Flutter build process. When flutter run --release
command is used to deploy and run the built APK, the APK that is installed to the device is copied to the flutter-apk
build folder before the finaliser plugin is completed. To fix this, copy the APK to the flutter-apk
build folder once finalisation is completed. This way Flutter will properly install the APK to the device.
Create a file called nevis-sdk-flutter-finalization.gradle
next to android/app/build.gradle
file with the following content:
project.afterEvaluate {
def finalizerTask = project.tasks.findByName("finalizeApkRelease")
if (finalizerTask != null) {
finalizerTask.doLast {
project.android.applicationVariants.all { variant ->
if (variant.name == "release") {
def outputDir = variant.packageApplicationProvider.get().outputDirectory.asFile.get()
variant.outputs.all { output ->
if (output.outputFileName.endsWith(".apk")) {
def sourceFile = new File(outputDir, output.outputFileName)
def destinationDir = new File(project.buildDir, "outputs/flutter-apk")
println "Copying finalized APK ${sourceFile.absolutePath} to ${destinationDir.absolutePath}"
project.copy {
from(sourceFile)
into(destinationDir)
}
}
}
}
}
}
}
}
Add the following code to the end of android/app/build.gradle
file:
apply from: 'nevis-sdk-flutter-finalization.gradle'
iOS
Dependency configuration
To integrate Nevis Mobile Authentication Client SDK into your Flutter application using CocoaPods, specify it in your Podfile:
pod 'NevisMobileAuthentication', :configurations => ['Release']
pod 'NevisMobileAuthentication-Debug', :configurations => ['Debug']
Bitcode support
As the native iOS SDK does not provide Bitcode support, the following post install step needs to be added to the Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO' # NMA SDK does not support Bitcode
end
end
end
Then execute pod install with update.
pod install --repo-update
Enable Face Recognition
Modify your applications Info.plist
file (located under ios/Runner) to add a description for the NSFaceIDUsageDescription
key to use the Face Recognition authenticator. Ideally, this value should be localized.
<key>NSFaceIDUsageDescription</key>
<string>Enabling Face ID allows you to use the Face Recognition authenticator.</string>