Subscription_Alert

Subscription Alert

A Flutter mobile app to track subscriptions and receive payment reminders.

Features

Tech Stack

Setup Instructions

Prerequisites

  1. Flutter SDK (>=3.0.0)
  2. Android Studio / VS Code
  3. Firebase account
  4. Node.js (for Firebase CLI)

Step 1: Clone and Install Dependencies

cd subscription_alert
flutter pub get

Step 2: Firebase Setup

  1. Create Firebase Project
    • Go to Firebase Console
    • Create a new project named β€œSubscription Alert”
    • Enable Google Analytics (optional)
  2. Add Android App
    • Package name: com.example.subscription_alert
    • Download google-services.json
    • Place it in android/app/
  3. Add iOS App (if building for iOS)
    • Bundle ID: com.example.subscriptionAlert
    • Download GoogleService-Info.plist
    • Place it in ios/Runner/
  4. Enable Firebase Services

    Authentication:

    • Go to Authentication > Sign-in method
    • Enable β€œGoogle” provider
    • Add your SHA-1 fingerprint for Android

    Firestore:

    • Go to Firestore Database
    • Create database in production mode
    • Set up security rules (see below)
  5. Configure FlutterFire (Recommended)
    # Install FlutterFire CLI
    dart pub global activate flutterfire_cli
       
    # Configure Firebase
    flutterfire configure
    

    This will update lib/firebase_options.dart with your configuration.

Step 3: Get SHA-1 Fingerprint (Android)

For Google Sign-In to work on Android:

# Debug key
cd android
./gradlew signingReport

Copy the SHA-1 fingerprint and add it to Firebase Console:

Step 4: Firestore Security Rules

In Firebase Console > Firestore > Rules, add:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // Users can only access their own data
    match /users/{userId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
      
      // Subscriptions subcollection
      match /subscriptions/{subscriptionId} {
        allow read, write: if request.auth != null && request.auth.uid == userId;
      }
    }
  }
}

Step 5: Run the App

# Android
flutter run

# iOS (macOS only)
cd ios && pod install && cd ..
flutter run

Project Structure

lib/
β”œβ”€β”€ main.dart                 # App entry point
β”œβ”€β”€ firebase_options.dart     # Firebase configuration
β”œβ”€β”€ models/
β”‚   └── subscription.dart     # Subscription data model
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ auth_service.dart     # Firebase Auth service
β”‚   β”œβ”€β”€ firestore_service.dart # Firestore CRUD operations
β”‚   └── notification_service.dart # Local notifications
β”œβ”€β”€ providers/
β”‚   β”œβ”€β”€ auth_provider.dart    # Auth state providers
β”‚   └── subscription_providers.dart # Subscription providers
β”œβ”€β”€ screens/
β”‚   β”œβ”€β”€ login_screen.dart     # Google Sign-In screen
β”‚   β”œβ”€β”€ home_screen.dart      # Main subscription list
β”‚   └── add_edit_subscription_screen.dart # Add/Edit form
└── widgets/
    └── subscription_list_item.dart # Subscription card widget

Firestore Data Model

users/
└── {userId}/
    └── subscriptions/
        └── {subscriptionId}/
            β”œβ”€β”€ name: String
            β”œβ”€β”€ price: Number
            β”œβ”€β”€ currency: String
            β”œβ”€β”€ cycle: String ("monthly" | "yearly")
            β”œβ”€β”€ nextPaymentDate: Timestamp
            β”œβ”€β”€ createdAt: Timestamp
            └── updatedAt: Timestamp

Notifications

The app schedules two notifications per subscription:

  1. 3 days before payment date (9:00 AM)
  2. On the payment date (9:00 AM)

Notifications persist after:

Customization

Change Default Currency

In lib/screens/add_edit_subscription_screen.dart:

static const List<String> _currencies = ['UZS', 'USD', 'EUR', 'RUB'];

Add More Billing Cycles

In lib/screens/add_edit_subscription_screen.dart:

static const List<String> _cycles = ['monthly', 'yearly', 'weekly'];

Don’t forget to update monthlyEquivalent in the model.

Troubleshooting

Google Sign-In Not Working (Android)

  1. Verify SHA-1 fingerprint is added to Firebase
  2. Check google-services.json is in android/app/
  3. Ensure Google Sign-In is enabled in Firebase Console

Notifications Not Showing

  1. Check notification permissions in device settings
  2. Verify the app has SCHEDULE_EXACT_ALARM permission
  3. On Android 13+, ensure POST_NOTIFICATIONS permission is granted

Build Errors

flutter clean
flutter pub get
cd android && ./gradlew clean && cd ..
flutter run

License

MIT License - feel free to use this for your own projects!