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

React Native plugin installation

Prerequisites

Your existing React Native application project has to meet the following prerequisites:

  • iOS 12.4 or later
  • Xcode 14.x, including Swift 5.7
  • 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.4.2 or later
  • Kotlin Gradle Plugin org.jetbrains.kotlin:kotlin-gradle-plugin 1.8.21 or later
  • React Native 0.72.x

Yarn

To integrate Nevis Mobile Authentication SDK React Native plugin into your React Native project execute this command:

yarn add @nevissecurity/[email protected]

This will also update your package.json and your yarn.lock so that other developers working on the project will get the same dependencies as you when they run yarn or yarn install.

Known Limitations

No Object destructuring support

Object destructuring is currently not supported by the Nevis Mobile Authentication Client SDK for React Native.

The current implementation relies heavily on using this inside functions defined in the API classes.

As consequence, if object destructuring is used to extract a function from any of the API classes, upon the execution of that destructured function, the this context will be different. This results in the Nevis Mobile Authentication Client SDK for React Native showing unexpected behaviour like errors at runtime.

How to circumvent this limitation

You can deal with this for example by invoking method calls the "old-fashioned way".

For example:

Instead of

const { cancelAuthentication } = await handler.listenForOsCredentials();

use

const authenticationListenHandler = await handler.listenForOsCredentials();
...
await authenticationListenHandler.cancelAuthentication();

Platform specific installation notes

Android

To install Nevis Mobile Authentication Client SDK for Android into your application follow the instructions of Android installation guide, the steps written have to be applied to the Android application part of your React Native project (e.g.: YOUR_REACT_NATIVE_PROJECT_PATH/android).

After the basic Android installation follow next chapters for React Native 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 React Native 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.7.+'
//noinspection GradleDynamicVersion
releaseImplementation 'ch.nevis:nevis-mobile-authentication-sdk-android:3.7.+'
}

Release build workaround

3.5.0 - 3.6.x only

The following workaround is only necessary for versions 3.5.0 - 3.6.0 of the Nevis Mobile Authentication SDK React Native plugin. When using newer versions, this section can be ignored.

Before the 3.7.0 release of the Nevis Mobile Authentication SDK React Native plugin there were an issue with the current React Native build process. When yarn android --mode release command was used to build (which internally uses the installRelease Gradle task), deploy and run the built release APK, the APK will be installed without running the finalization plugin. Finalization would properly run if the assembleRelease Gradle task is used instead. yarn can be instructed to do so with a flag: yarn android --tasks assembleRelease. This would create a finalized APK in the output folder (by default: android/app/build/outputs/apk/release/) but it will not deploy it to any device so yarn will fail to run it. To deploy this to a device you need to install it via adb, e.g.: adb install android/app/build/outputs/apk/release/app-release.apk from the root folder of your project.

iOS

Dependency configuration

To integrate Nevis Mobile Authentication Client SDK for iOS into your React Native application using CocoaPods, specify it in your ios/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) 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>