Skip to main content

Overview

Capacitor is the native runtime that powers Rodando Driver on Android and iOS devices. It provides a bridge between your Ionic/Angular web application and native platform APIs, enabling features like camera access, geolocation, push notifications, and more.

Current Configuration

The application’s Capacitor configuration is defined in capacitor.config.ts:
capacitor.config.ts
import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'io.ionic.starter',
  appName: 'rodandoApp-frontend',
  webDir: 'www'
};

export default config;
The default appId (io.ionic.starter) should be changed to a unique identifier for your application before building for production.

Configuration Properties

Required Properties

PropertyTypeCurrent ValueDescription
appIdstring'io.ionic.starter'Unique identifier for your app (reverse domain notation)
appNamestring'rodandoApp-frontend'Display name of your application
webDirstring'www'Directory containing the built web assets
Update the configuration for production deployment:
capacitor.config.ts
import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  appId: 'com.rodando.driver',              // Change to your domain
  appName: 'Rodando Driver',                 // User-facing app name
  webDir: 'www',
  
  // Platform-specific configurations
  android: {
    buildOptions: {
      keystorePath: 'path/to/keystore.jks',
      keystoreAlias: 'your-alias'
    }
  },
  
  ios: {
    contentInset: 'automatic',
    scheme: 'App'
  },
  
  // Server configuration for development
  server: {
    // Uncomment for live reload during development
    // url: 'http://192.168.1.100:8100',
    // cleartext: true
  },
  
  // Plugin configurations
  plugins: {
    SplashScreen: {
      launchShowDuration: 2000,
      backgroundColor: '#FFFFFF'
    },
    Keyboard: {
      resize: 'body',
      style: 'dark'
    }
  }
};

export default config;

Installed Capacitor Plugins

The application uses the following Capacitor plugins (from package.json):
package.json
{
  "dependencies": {
    "@capacitor/android": "7.4.2",
    "@capacitor/app": "7.0.1",
    "@capacitor/core": "7.4.2",
    "@capacitor/haptics": "7.0.1",
    "@capacitor/keyboard": "7.0.1",
    "@capacitor/preferences": "^7.0.2",
    "@capacitor/status-bar": "7.0.1",
    "capacitor-secure-storage-plugin": "^0.11.0"
  },
  "devDependencies": {
    "@capacitor/cli": "7.4.2"
  }
}

Plugin Reference

PluginVersionPurpose
@capacitor/app7.0.1App lifecycle events, deep linking, app state
@capacitor/haptics7.0.1Haptic feedback (vibration)
@capacitor/keyboard7.0.1Keyboard appearance and behavior
@capacitor/preferences7.0.2Local data storage (key-value pairs)
@capacitor/status-bar7.0.1Status bar styling and visibility
capacitor-secure-storage-plugin0.11.0Secure credential storage

Initial Setup

1

Install Capacitor

Capacitor is already installed. Verify installation:
npx cap --version
Expected output: 7.4.2 or similar
2

Update App Configuration

Edit capacitor.config.ts and update the appId:
const config: CapacitorConfig = {
  appId: 'com.yourcompany.rodando.driver', // Use your domain
  appName: 'Rodando Driver',
  webDir: 'www'
};
The appId must be unique and should follow reverse domain notation (e.g., com.company.app).
3

Build Web Assets

Before adding platforms, build your Angular application:
npm run build
This creates the www directory with compiled assets.
4

Add Platform(s)

Add Android and/or iOS platforms:
npx cap add android
This creates an android/ directory with a native Android project.
5

Sync Project

Copy web assets and Capacitor configuration to native projects:
npx cap sync
Run this command whenever you:
  • Change capacitor.config.ts
  • Install/update Capacitor plugins
  • Build new web assets

Development Workflow

Build and Sync

After making changes to your web code:
# Build Angular app
npm run build

# Sync to native projects
npx cap sync

Opening Native IDEs

Open native projects for building and debugging:
npx cap open android
This opens the android/ project in Android Studio.From Android Studio:
  1. Wait for Gradle sync to complete
  2. Select a device/emulator
  3. Click Run ▶️

Live Reload (Development)

Enable live reload for faster development:
1

Start Development Server

npm start
Note the IP address (e.g., http://192.168.1.100:4200)
2

Update Capacitor Config

capacitor.config.ts
const config: CapacitorConfig = {
  // ...
  server: {
    url: 'http://192.168.1.100:4200', // Your local IP
    cleartext: true
  }
};
3

Sync and Run

npx cap sync
npx cap run android # or ios
4

Disable for Production

Always comment out or remove the server configuration before building for production!

Platform-Specific Configuration

Android Configuration

Update Package Name

Edit android/app/build.gradle:
android/app/build.gradle
android {
    namespace "com.yourcompany.rodando.driver"
    defaultConfig {
        applicationId "com.yourcompany.rodando.driver"
        // ...
    }
}

Permissions

Add required permissions in android/app/src/main/AndroidManifest.xml:
AndroidManifest.xml
<manifest>
    <!-- Location permissions for driver tracking -->
    <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" />
    
    <!-- Network permissions -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    
    <!-- Camera permission (if needed) -->
    <uses-permission android:name="android.permission.CAMERA" />
    
    <!-- Notification permission (Android 13+) -->
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
</manifest>

Signing Configuration

For release builds, configure signing in capacitor.config.ts:
android: {
  buildOptions: {
    keystorePath: 'release.keystore',
    keystorePassword: process.env.KEYSTORE_PASSWORD,
    keystoreAlias: 'rodando-driver',
    keystoreAliasPassword: process.env.KEY_PASSWORD
  }
}

iOS Configuration

Update Bundle Identifier

Open Xcode and:
  1. Select your project in the navigator
  2. Select the target
  3. Go to Signing & Capabilities
  4. Update Bundle Identifier to com.yourcompany.rodando.driver

Permissions (Info.plist)

Add permission descriptions in ios/App/App/Info.plist:
Info.plist
<dict>
    <!-- Location permissions -->
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Rodando Driver needs your location to show nearby ride requests</string>
    
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>Rodando Driver needs background location to track active rides</string>
    
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Rodando Driver uses location in the background for ride tracking</string>
    
    <!-- Camera permission -->
    <key>NSCameraUsageDescription</key>
    <string>Rodando Driver needs camera access for profile photos</string>
    
    <!-- Photo library -->
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Rodando Driver needs access to save and upload photos</string>
</dict>

Plugin Configuration

Configure installed plugins in capacitor.config.ts:
capacitor.config.ts
const config: CapacitorConfig = {
  // ...
  plugins: {
    // Status Bar Configuration
    StatusBar: {
      style: 'dark', // 'light' or 'dark'
      backgroundColor: '#FFFFFF',
      overlaysWebView: false
    },
    
    // Keyboard Configuration
    Keyboard: {
      resize: 'body',     // 'native', 'body', 'ionic', or 'none'
      style: 'dark',      // 'light' or 'dark'
      resizeOnFullScreen: true
    },
    
    // Splash Screen Configuration
    SplashScreen: {
      launchShowDuration: 2000,
      backgroundColor: '#FFFFFF',
      showSpinner: false,
      androidSpinnerStyle: 'small',
      iosSpinnerStyle: 'small',
      spinnerColor: '#999999',
      splashFullScreen: false,
      splashImmersive: false
    },
    
    // App Configuration
    App: {
      handleRedirects: true
    },
    
    // Preferences (Storage) Configuration
    Preferences: {
      group: 'com.rodando.driver'
    }
  }
};

Using Capacitor Plugins

Example: Status Bar

src/app/app.component.ts
import { Component, OnInit } from '@angular/core';
import { StatusBar, Style } from '@capacitor/status-bar';
import { Platform } from '@ionic/angular';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html'
})
export class AppComponent implements OnInit {
  constructor(private platform: Platform) {}
  
  async ngOnInit() {
    await this.platform.ready();
    
    if (this.platform.is('capacitor')) {
      // Configure status bar
      await StatusBar.setStyle({ style: Style.Dark });
      await StatusBar.setBackgroundColor({ color: '#FFFFFF' });
    }
  }
}

Example: Haptics

import { Haptics, ImpactStyle } from '@capacitor/haptics';

// Trigger haptic feedback
await Haptics.impact({ style: ImpactStyle.Light });

// Notification haptics
await Haptics.notification({ type: 'success' });

Example: Preferences (Storage)

import { Preferences } from '@capacitor/preferences';

// Save data
await Preferences.set({
  key: 'driverId',
  value: '12345'
});

// Retrieve data
const { value } = await Preferences.get({ key: 'driverId' });
console.log('Driver ID:', value);

// Remove data
await Preferences.remove({ key: 'driverId' });

// Clear all data
await Preferences.clear();

Example: Secure Storage

import { SecureStoragePlugin } from 'capacitor-secure-storage-plugin';

// Store secure data (auth tokens, credentials)
await SecureStoragePlugin.set({
  key: 'authToken',
  value: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
});

// Retrieve secure data
const { value } = await SecureStoragePlugin.get({ key: 'authToken' });

// Remove secure data
await SecureStoragePlugin.remove({ key: 'authToken' });

Building for Production

Android Release Build

1

Create Keystore

Generate a release keystore (one-time setup):
keytool -genkey -v -keystore release.keystore \
  -alias rodando-driver \
  -keyalg RSA -keysize 2048 -validity 10000
Store the keystore file and passwords securely! You cannot update your app without them.
2

Build Web Assets

npm run build --configuration=production
npx cap sync android
3

Build APK/AAB

Open Android Studio:
npx cap open android
Then:
  1. BuildGenerate Signed Bundle / APK
  2. Select Android App Bundle (AAB) for Google Play
  3. Choose your keystore and enter credentials
  4. Select release build variant
  5. Click Finish
The signed AAB will be in android/app/release/

iOS Release Build

1

Apple Developer Account

Ensure you have:
  • Active Apple Developer account ($99/year)
  • Certificates and provisioning profiles configured
2

Build Web Assets

npm run build --configuration=production
npx cap sync ios
3

Configure Signing

Open Xcode:
npx cap open ios
  1. Select project → Target → Signing & Capabilities
  2. Enable Automatically manage signing
  3. Select your Team
  4. Verify bundle identifier matches App Store Connect
4

Archive and Upload

In Xcode:
  1. Select Any iOS Device as target
  2. ProductArchive
  3. When complete, click Distribute App
  4. Follow wizard to upload to App Store Connect

Troubleshooting

Plugin Not Found

Error: “Plugin [PluginName] not found” Solutions:
# Reinstall plugins
npm install

# Sync with native projects
npx cap sync

# If still failing, rebuild native projects
npx cap sync --force

Build Failing After Plugin Update

# Clean and rebuild
rm -rf node_modules package-lock.json
npm install
npx cap sync

# For Android
cd android && ./gradlew clean && cd ..

# For iOS
cd ios && rm -rf Pods Podfile.lock && pod install && cd ..

Live Reload Not Working

  1. Ensure device/emulator is on same network as development machine
  2. Verify server.url uses your local IP (not localhost)
  3. Check firewall isn’t blocking port 4200
  4. Disable VPN if active

Android Build Errors

Gradle build failed:
  1. Update Android Studio and Gradle
  2. Check Java version (JDK 17 recommended)
  3. Clean gradle cache:
    cd android
    ./gradlew clean
    

iOS Pod Installation Issues

cd ios/App
rm -rf Pods Podfile.lock
pod repo update
pod install

Next Steps

Environment Config

Configure environment variables for different builds

Google Maps Setup

Set up Google Maps API for navigation

Additional Resources

Build docs developers (and LLMs) love