Skip to main content

Capacitor SDK Installation

The DoorstepAI Capacitor SDK works with Angular, React, Vue, Next.js, Svelte, and other Capacitor applications. Examples in this guide use TypeScript; the plugin API is framework-independent.

Prerequisites​

  • Capacitor 7
  • Node.js 18+
  • A valid DoorstepAI API key
  • iOS 15+ or Android API 23+

Install​

npm install @doorstepai/dropoff-sdk-capacitor
npx cap sync

The current package name is @doorstepai/dropoff-sdk-capacitor. The exported plugin object is DoorstepAIDropoffSDK.

import { DoorstepAIDropoffSDK } from '@doorstepai/dropoff-sdk-capacitor';

Capacitor must point webDir at your framework's static build output:

capacitor.config.ts
import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
appId: 'com.yourapp.package',
appName: 'YourApp',
webDir: 'dist',
};

export default config;

After a web build, run npx cap sync again. For Next.js, use a static export and set webDir to out.

iOS configuration​

Add the usage descriptions and background location mode to ios/App/App/Info.plist:

ios/App/App/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>NSBluetoothAlwaysUsageDescription</key>
<string>This app requires access to Bluetooth for enhanced delivery intelligence</string>

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

Then install the native dependencies:

cd ios/App
pod install
cd ../..

Android configuration​

The Android SDK library contributes its tracking components and permission declarations through manifest merge. Add INTERNET, which the library does not declare, to android/app/src/main/AndroidManifest.xml:

android/app/src/main/AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application>
<!-- Your app components -->
</application>
</manifest>

The merged SDK manifest supplies the runtime location, activity, Bluetooth, nearby Wi-Fi, and notification permissions plus its foreground-service, wake-lock, network/Wi-Fi-state, boot, and legacy Bluetooth compatibility declarations. Inspect the Merged Manifest view for the exact result. Do not add neverForLocation to BLUETOOTH_SCAN or NEARBY_WIFI_DEVICES: the SDK uses nearby radio observations for positioning.

Runtime availability is OS-version dependent: Bluetooth scan is Android 12+, nearby Wi-Fi and notifications are Android 13+, and background location is a separate grant on Android 10+.

Verify the installation​

npm run build
npx cap sync
npx cap run ios # or: npx cap run android

Test the current export from code that runs after the Capacitor bridge has initialized:

import { Capacitor } from '@capacitor/core';
import { DoorstepAIDropoffSDK } from '@doorstepai/dropoff-sdk-capacitor';

if (Capacitor.isNativePlatform()) {
console.log('DoorstepAI plugin loaded:', !!DoorstepAIDropoffSDK);
}

The plugin is native-only. Do not call it during server rendering, pre-rendering, or build-time static generation.

Next steps​

  1. Initialize and use the SDK
  2. Implement runtime permissions
  3. See complete examples