For the complete documentation index, see llms.txt. This page is also available as Markdown.

Native Module Android

How to Create a Native Module in Android

This detailed guide explains how to create a expo module for the Android platform within a Expo application. The process follows the step-by-step instructions from the official documentation.

1. Open the Android Project in Android Studio

You can include this in your package.json under the scripts section:

"scripts": {
    "open:android": "open -a \"Android Studio\" android"
},

This script ensures that the Expo module opens correctly in Android Studio.

2. Create the Native Module

Create a file named CafSmartAuthBridgeModule.kt in the directory modules/caf-smart-auth-react-native/android/app/src/main/java/com/your-app-name/. This file will contain the class that implements the native module.

Key Functions of the CafSmartAuthBridgeModule Class

  • build: The build function is responsible for configuring and instantiating the CafSmartAuth object using the provided parameters. This function applies various settings, such as defining stages and facial authentication, to prepare the SDK for use.

  • setupListener: Sets up a listener to monitor the status of verification operations, such as success, pending, error, cancellation, and others.

  • requestPermission: Requests the necessary permissions, such as location permissions, for the proper functioning of the SDK.

  • startSmartAuth: Exposed to JavaScript, this function starts the smart authentication process using the received parameters.

  • requestLocationPermissions: Exposed to JavaScript, allows the application to request location permissions from the user.

Example Implementation of the CafSmartAuthBridgeModule.kt File

3. Create the CafSmartAuthBridgeSettings.kt File

This file will handle the interpretation of data sent from React Native to the native module.

Example Implementation:

With this, your native module is configured and ready to be used in React Native.

Last updated