Skip to main content

React Native SDK Installation

Get started with the DoorstepAI React Native SDK to add intelligent delivery tracking to your cross-platform application.

Prerequisites

Before you begin, ensure you have:

  • React Native 0.60+ with autolinking support
  • Valid API Key from DoorstepAI
  • iOS 15+ and Android API level 24+ deployment targets
  • Node.js 14+ and npm/yarn
Development Environment

We recommend using the latest stable version of React Native for the best development experience and access to the latest platform features.

Installation

Install the Package

Add the DoorstepAI React Native SDK to your project:

npm install @doorstepai/dropoff-sdk
# or
yarn add @doorstepai/dropoff-sdk

iOS Setup

For iOS, install the native dependencies:

cd ios && pod install && cd ..

Android Setup

For Android (React Native 0.60+), the SDK will be automatically linked via autolinking. No additional manual steps are required.

Platform-Specific Configuration

iOS Configuration

Update your ios/YourApp/Info.plist file with the required permissions:

ios/YourApp/Info.plist
<dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app requires access to your location for enhanced delivery intelligence</string>

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app requires access to your location for enhanced delivery intelligence</string>

<key>NSMotionUsageDescription</key>
<string>This app requires access to motion data for enhanced delivery intelligence</string>

<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>
</dict>

Android Configuration

Update your android/app/src/main/AndroidManifest.xml file with the required permissions:

android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourapp.package">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

<uses-permission android:name="android.permission.ACTIVITY_RECOGNITION" />

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

<uses-feature android:name="android.hardware.sensor.accelerometer" />
<uses-feature android:name="android.hardware.sensor.gyroscope" />
<uses-feature android:name="android.hardware.sensor.barometer" />
<uses-feature android:name="android.hardware.sensor.compass" />
<uses-feature android:name="android.hardware.sensor.proximity" />

<application>
<!-- Your app components -->
</application>
</manifest>

Permission Requirements

PermissionPurposePlatformRuntime Required
ACCESS_FINE_LOCATIONCore GPS trackingAndroidYes
ACCESS_COARSE_LOCATIONFallback when fine location is unavailableAndroidYes
ACCESS_BACKGROUND_LOCATIONTracking while the app is backgroundedAndroidYes
ACTIVITY_RECOGNITIONDrive/walk detectionAndroidYes
FOREGROUND_SERVICERequired host permission for foreground servicesAndroidNo
FOREGROUND_SERVICE_LOCATIONDeclares the location foreground service typeAndroidNo
FOREGROUND_SERVICE_DATA_SYNCDeclares the data sync foreground service typeAndroidNo
POST_NOTIFICATIONSShows the tracking status notificationAndroidYes
WAKE_LOCKPrevents the device from sleeping mid-deliveryAndroidNo
ACCESS_WIFI_STATEImproves location accuracy via WiFi signalsAndroidNo
ACCESS_NETWORK_STATEDetects connectivity for data syncAndroidNo
INTERNETSends tracking data to DoorstepAIAndroidNo
NSLocationWhenInUseUsageDescriptionForeground GPS trackingiOSYes
NSLocationAlwaysAndWhenInUseUsageDescriptionTracking while the app is backgroundediOSYes
NSMotionUsageDescriptionDrive/walk detection via motion sensorsiOSYes
NOTIFICATION PERMISSION (ANDROID 13+)

Starting with Android 13 (API level 33), apps must request the POST_NOTIFICATIONS permission at runtime.

Verification

To verify the installation was successful:

  1. Build your project:

    # iOS
    npx react-native run-ios

    # Android
    npx react-native run-android
  2. Check for import errors in files using the SDK

  3. Verify permissions are properly configured in platform-specific files

  4. Test the import in your React Native app:

    App.js
    import { DoorstepAI, RootDoorstepAI } from '@doorstepai/dropoff-sdk';

    // Test basic import
    console.log('DoorstepAI SDK imported successfully');

Troubleshooting Installation

Common Issues

Build Errors

  • Error: "Could not resolve dependency"
    • Solution: Check internet connection and verify the package name
    • Solution: Ensure you're using the correct version number

iOS Pod Install Issues

  • Error: "Pod install failed"
    • Solution: Run cd ios && pod install --repo-update && cd ..
    • Solution: Clean build folder: cd ios && xcodebuild clean && cd ..

Android Build Issues

  • Error: "Native module not found"
    • Solution: Ensure autolinking is enabled (React Native 0.60+)
    • Solution: Clean and rebuild: cd android && ./gradlew clean && cd ..

Next Steps

Now that you have the SDK installed and configured:

  1. 📚 Learn SDK Usage - Initialize and use the SDK
  2. 💡 View Examples - See complete implementation examples
Ready to Implement?

Head over to our Usage Guide to learn how to implement the SDK and start using delivery tracking in your React Native app.