Logo
React native

Installation

Installation

Standard React Native

  1. Obtain the package file:

    Get the react-native-n2app-0.1.0.tgz file from your package provider.

  2. Install the package:

    Place the .tgz file in your project root, then:

    npm install ./react-native-n2app-0.1.0.tgz
    # or
    yarn add ./react-native-n2app-0.1.0.tgz
  3. Clean and link native dependencies:

    cd android && ./gradlew clean
    cd ..

Expo (Managed Workflow)

  1. Obtain the package file:

    Get the react-native-n2app-0.1.0.tgz file from your package provider.

  2. Install the package:

    Place the .tgz file in your project root, then:

    npm install ./react-native-n2app-0.1.0.tgz
    # or
    yarn add ./react-native-n2app-0.1.0.tgz
  3. Prebuild to generate native folders:

    npx expo prebuild --clean
  4. Continue with Android Configuration below


Android Configuration

Step 1: Configure Root-Level build.gradle

Add the flatDir repository to make the N2app AAR library accessible.

File: android/build.gradle

allprojects {
  repositories {
    google()
    mavenCentral()
    maven { url 'https://www.jitpack.io' }

    // Add this flatDir configuration
    flatDir {
      dirs "${rootProject.projectDir}/../node_modules/react-native-n2app/android/libs/"
    }
  }
}

For Expo projects, the allprojects block should look like:

allprojects {
  repositories {
    google()
    mavenCentral()
    maven { url 'https://www.jitpack.io' }
    flatDir {
      dirs "${rootProject.projectDir}/../node_modules/react-native-n2app/android/libs/"
    }
  }
}

apply plugin: "expo-root-project"
apply plugin: "com.facebook.react.rootproject"

Step 2: Update build.gradle to Set Minimum SDK Version

Ensure your app's minimum SDK version is set to 26 or higher.

File: android/build.gradle

Add or update the following in the buildscript section:

buildscript {
    ext {
        buildToolsVersion = "34.0.0"
        minSdkVersion = 26
        compileSdkVersion = 34
        targetSdkVersion = 34
        kotlinVersion = "1.9.0"
    }
    // ... rest of buildscript
}

Step 3: Configure AndroidManifest.xml

File: android/app/src/main/AndroidManifest.xml

Add SoftPOS package queries, and metadata configuration:

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Add queries to allow interaction with SoftPOS app -->
    <queries>
        <intent>
            <action android:name="android.intent.action.PROCESS_TEXT"/>
            <data android:mimeType="text/plain"/>
        </intent>
        <package android:name="com.neurogine.softpos.stage" />
    </queries>

    <application>
        <!-- Configure the SoftPOS package name -->
        <meta-data
            android:name="softposName"
            android:value="com.neurogine.softpos.stage" />

        <!-- Your existing application configuration -->
    </application>
</manifest>

Important Notes:

  • The <queries> section must be placed outside the <application> tag but inside <manifest>
  • The <meta-data> section must be placed inside the <application> tag
  • Update the package name in both locations to match your SoftPOS environment:
    • Use com.neurogine.softpos for production
    • Use com.neurogine.softpos.stage for staging/testing

Step 4: Environment-Specific Configuration

The SoftPOS package name should match your target environment:

  • Production:
<meta-data android:name="softposName" android:value="com.neurogine.softpos" />
<queries>
    <package android:name="com.neurogine.softpos" />
</queries>
  • Staging / Testing:
<meta-data android:name="softposName" android:value="com.neurogine.softpos.stage" />
<queries>
    <package android:name="com.neurogine.softpos.stage" />
</queries>

Note: The package names in <meta-data> and <queries> must match the actual package name of the installed SoftPOS app on your device.

Step 5: Clean and Rebuild

cd android
./gradlew clean
cd ..

# For standard React Native
npx react-native run-android

# For Expo
npx expo run:android

On this page