@hituchhimpa/react-native-entrupy
v1.0.4
Published
React Native wrapper for Entrupy SDK
Readme
react-native-entrupy
A robust, developer-friendly React Native wrapper for the Entrupy SDK. This library allows you to easily integrate Entrupy's authentication and capture services into your React Native iOS and Android applications.
🛑 Prerequisites (Important)
Before you begin, you must register your application with Entrupy:
- Register Package Names: You need to register your Android
applicationIdand iOSBundle Identifieron the Entrupy Developer Portal. If these are not registered, the SDK will fail to authenticate. - Entrupy Credentials: Obtain your Entrupy access tokens/keys from your Entrupy dashboard.
- Private Repository Access: If this repository is hosted privately, ensure that the user installing it has their Git username and Personal Access Token (PAT) configured in their system to fetch the package.
📦 Installation
Install the package using your preferred package manager:
# Using npm
npm install @hituchhimpa/react-native-entrupy
# Using yarn
yarn add @hituchhimpa/react-native-entrupy🍎 iOS Setup
After installing the package, you need to install the iOS dependencies via CocoaPods:
cd ios
pod install
cd ..Note: Make sure your iOS deployment target in Podfile matches the Entrupy SDK minimum requirements (usually iOS 13.0+).
🤖 Android Setup
Auto-linking handles the project setup for Android, but since the Entrupy Android SDK is hosted on a private GitHub Maven registry, you MUST provide GitHub credentials to download it during the build process.
- Ensure your
minSdkVersionin your app'sandroid/build.gradleis set to API 24 or higher. - Add the Entrupy Maven repository to your root
android/build.gradleunder theallprojects>repositoriesblock. You MUST provide your GitHub credentials to download it. You can set them as environment variables (GITHUB_USERandGITHUB_TOKEN) or add them to your~/.gradle/gradle.properties:
allprojects {
repositories {
// ... other repositories ...
maven {
url = uri("https://maven.pkg.github.com/entrupy/entrupy-sdk-android")
credentials {
username = providers.gradleProperty("gpr.user").orNull ?: providers.environmentVariable("GITHUB_USER").orNull ?: ""
password = providers.gradleProperty("gpr.token").orNull ?: providers.environmentVariable("GITHUB_TOKEN").orNull ?: ""
}
}
}
}If these are missing, your Android build will fail with a 401 Unauthorized or "Could not find com.entrupy:sdk" error during the final linking phase.
🛠 Usage
Here is a complete example of how to use the SDK in your app:
import React, { useState } from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
import {
startCapture,
generateAuthorizationRequest,
} from '@hituchhimpa/react-native-entrupy';
export default function App() {
const [status, setStatus] = useState<string>('Ready');
const handleStartCapture = async () => {
try {
setStatus('Starting capture session...');
// Make sure your bundle ID / package name is registered on Entrupy!
const isSuccess = await startCapture(
'Bags',
'Gucci',
'Handbag',
'item_12345'
);
setStatus(`Capture Success: ${isSuccess}`);
} catch (error: any) {
setStatus(`Error: ${error.message}`);
}
};
return (
<View style={styles.container}>
<Text style={styles.status}>Status: {status}</Text>
<Button title="Start Entrupy Capture" onPress={handleStartCapture} />
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1, justifyContent: 'center', alignItems: 'center' },
status: { fontSize: 16, marginBottom: 20, fontWeight: 'bold' },
});🧹 Troubleshooting & Clean Builds
Sometimes React Native caches can cause issues. If you face any native build errors, run the following commands to clean your project:
Clean Android
cd android
./gradlew clean
cd ..
# To rebuild
npx react-native run-androidClean iOS
cd ios
rm -rf Pods Podfile.lock
pod install --repo-update
cd ..
# To rebuild
npx react-native run-iosClean React Native Cache (Metro)
npm start -- --reset-cache
# or with Yarn
yarn start --reset-cache🤝 Contributing
📄 License
MIT
Made with ❤️ by hituchhimpa7
