Skip to main content

Install for React Native

Use your Mobai read-only access token to install @mobaibio/mobai-biometric version 2.3.3 from the private Cloudsmith npm registry. To get a token, contact support at support@mobai.bio.

The React Native package depends on the native SDKs, so a React Native app needs three registries configured with the same token:

PartPackageRegistry
JavaScript@mobaibio/mobai-biometric 2.3.3Cloudsmith npm
iOSMobaiBiometric 2.3.3 (pinned by the React Native package)Cloudsmith CocoaPods
Androidbio.mobai:biometric:2.3.3 (pinned by the React Native package)Cloudsmith Maven

The package supports React Native 0.61 to 0.86 and React up to 19.2.3. See the React Native Quick Start requirements.

The examples below read the token from the MOBAI_ACCESS_TOKEN environment variable or from user-level files. Do not commit the token to your repository.

1. Configure npm or Yarn​

Map only the @mobaibio scope to Cloudsmith. Other packages continue to come from your default registry.

npm and Yarn 1​

Create or extend .npmrc in your project root:

@mobaibio:registry=https://npm.cloudsmith.io/mobai/sdks/
//npm.cloudsmith.io/mobai/sdks/:_authToken=${MOBAI_ACCESS_TOKEN}

npm reads ${MOBAI_ACCESS_TOKEN} from the environment when it runs, so this file contains no secret and can be committed. Export the variable in your shell profile or CI secret before installing.

Yarn 2 and later​

Add the scope to .yarnrc.yml:

npmScopes:
mobaibio:
npmRegistryServer: "https://npm.cloudsmith.io/mobai/sdks/"
npmAlwaysAuth: true
npmAuthToken: "${MOBAI_ACCESS_TOKEN}"

Install the package​

npm install @mobaibio/mobai-biometric@2.3.3

or

yarn add @mobaibio/mobai-biometric@2.3.3

If your project already depends on @mobaibio/mobai-biometric from npmjs.com, remove the old entry from your lock file (or run the install command above) so that the package is resolved from Cloudsmith.

2. Configure iOS (CocoaPods)​

The React Native package pins MobaiBiometric 2.3.3, which is served from Mobai's Cloudsmith CocoaPods repository. Follow Install on iOS with CocoaPods to store the token in ~/.netrc, then add the Mobai spec source to ios/Podfile:

source 'https://dl.cloudsmith.io/basic/mobai/sdks/cocoapods/index.git'
source 'https://cdn.cocoapods.org/'

React Native apps also need static frameworks, a dynamic SwiftProtobuf and a minimum pod deployment target. See the complete Podfile in the React Native Quick Start. Then install the pods:

cd ios && pod install --repo-update

3. Configure Android (Gradle)​

The React Native package pins bio.mobai:biometric:2.3.3. Follow the Android token and repository setup, and add the repository to the allprojects.repositories block in android/build.gradle as shown in the React Native Quick Start.

Troubleshooting​

  • npm ERR! ERESOLVE mentioning react or react-native: your project uses a React Native or React version that 2.3.3 does not support yet. Use React Native 0.86 or earlier.
  • npm ERR! 404 or 401 for @mobaibio/mobai-biometric: confirm that MOBAI_ACCESS_TOKEN is exported in the shell that runs npm or Yarn and that the scope line is spelled @mobaibio:registry.
  • An older version is installed: your lock file still points to npmjs.com. Reinstall with @2.3.3 as shown above.
  • Unable to find a specification for MobaiBiometric (= 2.3.3): the Cloudsmith source is missing from ios/Podfile or the ~/.netrc entry for dl.cloudsmith.io is missing. Run pod repo update after fixing it.
  • underlying Objective-C module 'SwiftProtobuf' not found: add use_frameworks! :linkage => :static and the SwiftProtobuf pre_install block from the Quick Start Podfile.
  • The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0: add the deployment-target loop from the Quick Start Podfile to post_install.
  • The app closes immediately at launch on iOS 27: adopt the UIScene lifecycle as described in iOS 27: adopt the UIScene lifecycle.
  • Gradle cannot resolve bio.mobai:biometric:2.3.3: see Install on Android.
  • Error resolving plugin [id: 'com.facebook.react.settings']: build Android with JDK 17.