#!/bin/bash

# Cordova Audio Recorder Plugin Installation Script
# This script helps install the plugin in a Cordova project

echo "=========================================="
echo "Cordova Audio Recorder Plugin Installer"
echo "=========================================="

# Check if we're in a Cordova project
if [ ! -f "config.xml" ]; then
    echo "Error: config.xml not found. Please run this script from a Cordova project root directory."
    exit 1
fi

# Check if Cordova CLI is installed
if ! command -v cordova &> /dev/null; then
    echo "Error: Cordova CLI is not installed. Please install it first:"
    echo "npm install -g cordova"
    exit 1
fi

echo "Installing Cordova Audio Recorder Plugin..."

# Add the plugin
cordova plugin add ./cordova-plugin-audio-recorder

if [ $? -eq 0 ]; then
    echo "✅ Plugin installed successfully!"
    echo ""
    echo "Next steps:"
    echo "1. Add iOS platform if not already added:"
    echo "   cordova platform add ios"
    echo ""
    echo "2. Build the project:"
    echo "   cordova build ios"
    echo ""
    echo "3. Open in Xcode:"
    echo "   cordova run ios"
    echo ""
    echo "4. Make sure to add microphone permission to Info.plist:"
    echo "   <key>NSMicrophoneUsageDescription</key>"
    echo "   <string>This app needs access to microphone to record audio.</string>"
    echo ""
    echo "Usage example:"
    echo "navigator.audioRecorder.startRecording(success, error, options);"
else
    echo "❌ Plugin installation failed!"
    exit 1
fi 