Configuration

Environment variables and app configuration guide

Environment Configuration

Missão uses environment files to manage configuration for different environments (development, staging, production). Configuration is passed to Flutter via --dart-define-from-file.

Security: Never commit .env files with real credentials to version control. Add them to your .gitignore.

Creating Environment Files

# Create environment files
cp .env.example .env.dev
cp .env.example .env.staging
cp .env.example .env.prod

Complete Environment Variables Reference

# =========================================
# APP CONFIGURATION
# =========================================
FLAVOR=dev                              # dev, staging, or prod
APP_NAME=Missão                         # Display name of the app
APP_VERSION=1.0.0                       # App version (semver)

# =========================================
# FIREBASE CONFIGURATION
# =========================================
FIREBASE_API_KEY=AIzaSy...              # Firebase API Key
FIREBASE_APP_ID=1:123456:android:abc    # Firebase App ID
FIREBASE_PROJECT_ID=your-project-id    # Firebase Project ID
FIREBASE_MESSAGING_SENDER_ID=123456    # FCM Sender ID
FIREBASE_STORAGE_BUCKET=your-project.appspot.com

# =========================================
# GOOGLE MAPS
# =========================================
GOOGLE_MAPS_API_KEY_ANDROID=AIzaSy...  # Maps key for Android
GOOGLE_MAPS_API_KEY_IOS=AIzaSy...      # Maps key for iOS
GOOGLE_MAPS_API_KEY_WEB=AIzaSy...      # Maps key for Web
GEOCODING_API_KEY=AIzaSy...            # Geocoding API key

# =========================================
# FEATURE FLAGS
# =========================================
USE_FIREBASE_EMULATORS=false           # Use local emulators
ENABLE_ANALYTICS=true                  # Firebase Analytics
ENABLE_CRASHLYTICS=true                # Firebase Crashlytics
ENABLE_PERFORMANCE=true                # Firebase Performance
ENABLE_DEBUG_LOGS=false                # Debug logging

# =========================================
# ADMIN PANEL
# =========================================
ADMIN_PANEL_URL=https://admin.yourdomain.com

# =========================================
# FCM WEB PUSH
# =========================================
FCM_VAPID_KEY=BL...                    # VAPID key for web push

Google Maps Configuration

Step 1: Create API Keys

  1. Go to Google Cloud Console
  2. Select your project (or create one linked to Firebase)
  3. Go to APIs & Services → Credentials
  4. Click Create Credentials → API Key

Step 2: Enable Required APIs

Enable these APIs in Google Cloud Console:

API Usage
Maps SDK for Android Map display on Android
Maps SDK for iOS Map display on iOS
Maps JavaScript API Map display on Web
Geocoding API Address-to-coordinates conversion
Places API Place search and autocomplete

Step 3: Restrict API Keys

For security, restrict each key:

Android Key

iOS Key

Web Key

Step 4: Configure Keys in Project

Android: android/app/src/main/AndroidManifest.xml

<manifest ...>
    <application ...>
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="${GOOGLE_MAPS_API_KEY_ANDROID}"/>
    </application>
</manifest>

iOS: ios/Runner/AppDelegate.swift

import GoogleMaps

@UIApplicationMain
class AppDelegate: FlutterAppDelegate {
    override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        GMSServices.provideAPIKey("YOUR_IOS_API_KEY")
        // ... rest of setup
    }
}

Web: web/index.html

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_WEB_API_KEY"></script>

SendGrid Email Configuration

Step 1: Create SendGrid Account

  1. Go to SendGrid
  2. Create a free account
  3. Verify your email and identity

Step 2: Generate API Key

  1. Go to Settings → API Keys
  2. Click Create API Key
  3. Give it a name (e.g., "Missão Email")
  4. Select Full Access or Restricted Access (Mail Send only)
  5. Copy the generated key (starts with SG.)

Step 3: Configure Firebase Extension

Edit extensions/firestore-send-email.env:

LOCATION=southamerica-east1
DATABASE_REGION=southamerica-east1
MAIL_COLLECTION=mail
DEFAULT_FROM=noreply@yourdomain.com
DEFAULT_REPLY_TO=support@yourdomain.com
SMTP_CONNECTION_URI=smtps://apikey:SG.YOUR_API_KEY_HERE@smtp.sendgrid.net:465
SMTP_PASSWORD=
TTL_EXPIRE_TYPE=never
TTL_EXPIRE_VALUE=
USERS_COLLECTION=
TEMPLATES_COLLECTION=

Step 4: Configure Sender Identity

  1. In SendGrid, go to Settings → Sender Authentication
  2. Verify your domain or single sender email
  3. Use the verified email as DEFAULT_FROM
Note: For production, domain verification is recommended over single sender verification.

iOS Configuration

Bundle Identifier

Update ios/Runner.xcodeproj/project.pbxproj or via Xcode:

  1. Open ios/Runner.xcworkspace in Xcode
  2. Select the Runner project
  3. Change Bundle Identifier to your company's identifier

Info.plist Configuration

Edit ios/Runner/Info.plist:

<key>CFBundleDisplayName</key>
<string>$(APP_NAME)</string>

<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to find nearby parishes.</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>We need your location to notify you about nearby parishes.</string>

<key>NSCameraUsageDescription</key>
<string>We need camera access to take profile photos.</string>

<key>NSPhotoLibraryUsageDescription</key>
<string>We need photo library access to select profile photos.</string>

Google Sign-In URL Scheme

Add your reversed client ID from GoogleService-Info.plist:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>com.googleusercontent.apps.YOUR_CLIENT_ID</string>
        </array>
    </dict>
</array>

Apple Sign-In Capability

  1. Open Xcode → Runner → Signing & Capabilities
  2. Click + Capability
  3. Add Sign in with Apple

Android Configuration

Application ID

Edit android/app/build.gradle.kts:

android {
    namespace = "com.yourcompany.missao"

    defaultConfig {
        applicationId = "com.yourcompany.missao"
        minSdk = 23
        targetSdk = 34
        versionCode = 1
        versionName = "1.0.0"
    }
}

Signing Configuration

  1. Generate a keystore:
    keytool -genkey -v -keystore ~/upload-keystore.jks \
        -keyalg RSA -keysize 2048 -validity 10000 \
        -alias upload
  2. Create android/key.properties:
    storePassword=your_store_password
    keyPassword=your_key_password
    keyAlias=upload
    storeFile=/path/to/upload-keystore.jks
  3. Configure in build.gradle.kts:
    val keystorePropertiesFile = rootProject.file("key.properties")
    val keystoreProperties = Properties()
    if (keystorePropertiesFile.exists()) {
        keystoreProperties.load(FileInputStream(keystorePropertiesFile))
    }
    
    android {
        signingConfigs {
            create("release") {
                storeFile = file(keystoreProperties["storeFile"] as String)
                storePassword = keystoreProperties["storePassword"] as String
                keyAlias = keystoreProperties["keyAlias"] as String
                keyPassword = keystoreProperties["keyPassword"] as String
            }
        }
    
        buildTypes {
            release {
                signingConfig = signingConfigs.getByName("release")
            }
        }
    }
Important: Never commit key.properties or your keystore file to version control!

SHA-1 Fingerprint for Firebase

# Debug fingerprint
./gradlew signingReport

# Add the SHA-1 to Firebase Console → Project Settings → Your Apps → Android

Cloud Functions Configuration

Environment Variables

Set function configuration via Firebase CLI:

# Set admin panel URL
firebase functions:config:set app.admin_url="https://admin.yourdomain.com"

# Set email sender
firebase functions:config:set email.sender="noreply@yourdomain.com"

# Deploy to apply changes
firebase deploy --only functions

Runtime Configuration

Edit functions/.runtimeconfig.json for local development:

{
    "app": {
        "admin_url": "http://localhost:5000"
    },
    "email": {
        "sender": "noreply@yourdomain.com"
    }
}

Running with Different Environments

Development

flutter run --dart-define-from-file=.env.dev

Staging

flutter run --dart-define-from-file=.env.staging

Production

flutter run --release --dart-define-from-file=.env.prod

With Firebase Emulators

# Terminal 1: Start emulators
firebase emulators:start

# Terminal 2: Run app with USE_FIREBASE_EMULATORS=true in .env.dev
flutter run --dart-define-from-file=.env.dev

Localization Configuration

Supported Languages

Missão supports multiple languages out of the box:

Language Code ARB File
Portuguese (Brazil) pt lib/l10n/app_pt.arb
English en lib/l10n/app_en.arb

Adding a New Language

  1. Create a new ARB file: lib/l10n/app_XX.arb
  2. Copy content from an existing ARB file
  3. Translate all strings
  4. Run flutter gen-l10n

l10n.yaml Configuration

arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
output-class: AppLocalizations
synthetic-package: false
output-dir: lib/l10n/generated

Next Steps

With configuration complete, proceed to:

  1. Deployment - Deploy to production
  2. Customization - Customize branding and features