Skip to main content
Version: 3.6.x.x RR

Flutter plugin installation

Prerequisites

Your existing Flutter application project has to meet the following prerequisites:

  • iOS 12 or later
  • Xcode 14.3.1, including Swift 5.8.1 or later
  • Android 6 or later, with API level 23
  • 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.0.0 or later
  • Kotlin Gradle Plugin org.jetbrains.kotlin:kotlin-gradle-plugin 1.6.0 or later
  • Flutter SDK 3.x, stable channel

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):

pubspec.yaml
  dependencies:
nevis_mobile_authentication_sdk: ^3.6.0

Manual integration

Alternatively, you can edit your pubspec.yaml file manually:

pubspec.yaml
  dependencies:
flutter:
sdk: flutter

...
nevis_mobile_authentication_sdk: ^3.6.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:

android.useAndroidX=true
android.enableJetifier=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.

Nevis Mobile Authentication Client SDK dependecies
dependencies {
//noinspection GradleDynamicVersion
debugImplementation 'ch.nevis:nevis-mobile-authentication-sdk-android-debug:3.6.+'
//noinspection GradleDynamicVersion
releaseImplementation 'ch.nevis:nevis-mobile-authentication-sdk-android:3.6.+'
}

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:

nevis-sdk-flutter-finalization.gradle
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:

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:

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.

Info.plist
<key>NSFaceIDUsageDescription</key>
<string>Enabling Face ID allows you to use the Face Recognition authenticator.</string>