react-native-geosentry
v1.0.12
Published
React Native SDK for Geosentry location services integration
Maintainers
Readme
react-native-geosentry
A React Native SDK for integrating Geosentry location services into your mobile applications.
Installation
npm install react-native-geosentry
# or
yarn add react-native-geosentrySetup
iOS
- Add the following to your Podfile:
pod 'react-native-geosentry', :path => '../node_modules/react-native-geosentry'- Run pod install:
cd ios && pod install- For proper location tracking, ensure your Info.plist contains the required location permission keys:
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to provide you with relevant services.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>We need to track your location in the background to provide you with relevant alerts.</string>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>Android
No additional linking required. The package will be automatically linked.
In your AndroidManifest.xml, ensure you have the following permissions:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />Android AAR Integration
This package includes the Geosentry Android SDK as an AAR file (android/libs/geosentry_sdk_uat.aar).
When you install this package, the AAR file will be available in your node_modules directory and automatically linked via Gradle. No manual steps are required unless you need to use a different AAR file.
If you need to use a custom AAR, replace the file in android/libs/ and rebuild your project.
Usage
import Geosentry from 'react-native-geosentry';
// Initialize the SDK
const initializeSDK = async () => {
try {
const apiKey = 'YOUR_API_KEY';
const cipherKey = 'YOUR_CIPHER_KEY';
const userID = 'USER_ID';
const response = await Geosentry.initializeSDK(apiKey, cipherKey, userID);
console.log('SDK Initialization Success:', response);
} catch (error) {
console.error('SDK Initialization Error:', error);
}
};
// Stop location tracking
const stopLocationTracking = async () => {
try {
const response = await Geosentry.stopTracking();
console.log('Tracking stopped:', response);
} catch (error) {
console.error('Failed to stop tracking:', error);
}
};API Reference
initializeSDK(apiKey: string, cipherKey: string, userID: string): Promise<any>
Initializes the Geosentry SDK with the provided credentials. This will also request necessary permissions for location tracking.
Parameters:
apiKey: Your Geosentry API keycipherKey: Your Geosentry cipher keyuserID: Unique identifier for the user
Returns:
A promise that resolves when the SDK is successfully initialized.
stopTracking(): Promise<string>
Stops the location tracking service.
Returns:
A promise that resolves with a success message when tracking is successfully stopped.
Requirements
- iOS: 13.0 or higher
- Android: API level 23 (Marshmallow) or higher
- React Native: 0.63 or higher
Troubleshooting
iOS
- If you encounter
Undefined symbolerrors during build, ensure that the Geosentry_SDK.framework is properly embedded in your app target.
Android
- For Android 11+ (API level 30+), ensure you have added the background location permission to your manifest and are requesting it at runtime.
License
MIT
