A Flutter mobile application implementing Firebase Cloud Messaging (FCM) with Firestore database integration and Firebase Hosting for notifications history.
This project consists of three main tasks:
- Simple form to collect social media group name and type
- Store multiple group entries in Firestore
- Display stored groups in a list view
- Receive cloud messages in foreground and background
- Handle topic subscription via data message with key
subscribeToTopic - Handle topic unsubscription via data message with key
unsubscribeToTopic - Store all received messages in Firestore
- Fetch and display all stored notifications from Firestore
- Show both notification and data payloads
- Host the page using Firebase Hosting
- Flutter SDK (3.35.7 or later)
- Android Studio with Android SDK
- Node.js and npm (for Firebase CLI)
- Firebase Account
git clone https://github.com/Yamenxy/cloud_computing.git
cd cloud_computingflutter pub get- Go to Firebase Console
- Create a new project or use existing:
cloud-comuting-ccc74
- In Firebase Console β Project Settings β Add Android App
- Package name:
com.example.task_1 - Download
google-services.json - Place it in:
android/app/google-services.json
- In Firebase Console β Project Settings β Add Web App
- App nickname:
Cloud Computing Web - Copy the
firebaseConfigobject - Update
web/notifications.html(around line 167) with your config
- Firebase Console β Firestore Database β Create Database
- Start in test mode or use these security rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}- Firebase Console β Cloud Messaging
- Ensure Cloud Messaging API is enabled
flutter devices# Launch emulator (if not running)
flutter emulators --launch Medium_Phone_API_36.1
# Run the app
flutter run -d emulator-5554# List connected devices
adb devices
# Run on specific device
flutter run -d <device-id>flutter build apk --releaseThe APK will be located at: build/app/outputs/flutter-apk/app-release.apk
flutter clean
flutter pub get
flutter runWhile app is running:
- Press
rfor hot reload - Press
Rfor hot restart - Press
qto quit
flutter doctor -vflutter pub upgradeflutter testnpm install -g firebase-toolsfirebase loginThe project already has firebase.json and .firebaserc configured.
firebase deploy --only hostingAfter deployment, your notifications page will be available at:
https://cloud-comuting-ccc74.web.app/notifications
- Run the app on emulator/device
- Check the console logs for:
π FCM Token: ... - Copy the token for testing
- Go to Firebase Console β Cloud Messaging
- Click "Send your first message" or "New campaign"
- Enter notification details:
- Title: "Test Notification"
- Text: "This is a test message"
- Click "Send test message"
- Paste your FCM token
- Click Test
- Firebase Console β Cloud Messaging β New message
- Click "Send test message"
- Under "Additional options" β "Custom data"
- Add key-value pair:
- Key:
subscribeToTopic - Value:
sports(or any topic name)
- Key:
- Paste FCM token and send
- Check app logs for:
β Subscribed to topic: sports
- Create new message in Firebase Console
- Select Topic as target
- Enter topic name:
sports - Send notification
- App should receive it
- Send test message with custom data:
- Key:
unsubscribeToTopic - Value:
sports
- Key:
- Check logs for:
β Unsubscribed from topic: sports
cloud_computing/
βββ android/ # Android native code
β βββ app/
β β βββ google-services.json # Firebase Android config
β β βββ src/main/
β β βββ AndroidManifest.xml # FCM permissions
βββ lib/
β βββ main.dart # Main Flutter application
βββ web/
β βββ index.html # Flutter web app
β βββ notifications.html # Notifications history page
βββ firebase.json # Firebase Hosting config
βββ .firebaserc # Firebase project config
βββ pubspec.yaml # Flutter dependencies
βββ README.md # This file
dependencies:
flutter:
sdk: flutter
firebase_core: ^3.5.0 # Firebase initialization
cloud_firestore: ^5.4.4 # Firestore database
firebase_messaging: ^15.1.3 # Cloud Messaging
firebase_analytics: ^11.3.3 # Analytics (optional)
cupertino_icons: ^1.0.8 # iOS icons- Form to add social media groups (name & type)
- Submit button to save to Firestore
- Notifications icon (π) to view message history
- Groups list icon (π) to view stored groups
- Real-time display of all FCM messages
- Statistics dashboard (Total, Today)
- Expandable cards showing:
- Notification title and body
- Data payload (JSON format)
- Timestamp with smart formatting
- Beautiful purple gradient UI
- List of all stored social media groups
- Real-time updates from Firestore
- Project Console: https://console.firebase.google.com/project/cloud-comuting-ccc74
- Firestore Database: https://console.firebase.google.com/project/cloud-comuting-ccc74/firestore
- Cloud Messaging: https://console.firebase.google.com/project/cloud-comuting-ccc74/messaging
- Hosting: https://console.firebase.google.com/project/cloud-comuting-ccc74/hosting
# Add Flutter to PATH (Windows PowerShell)
$env:Path += ";C:\src\flutter\bin"
# Verify
flutter --version# Clean and rebuild
flutter clean
flutter pub get
flutter run- Ensure
google-services.jsonis inandroid/app/ - Check package name matches:
com.example.task_1 - Rebuild the app
- Check Firestore security rules allow read/write
- Verify FCM token is correct
- Check app logs for errors
# Re-login
firebase logout
firebase login
# Deploy again
firebase deploy --only hosting- β Add social media groups
- β View stored groups
- β Receive FCM notifications (foreground & background)
- β View notifications history
- β Subscribe/unsubscribe to topics
- β Store messages in Firestore
- β Web-based notifications dashboard
- Developer: Ahmed
- Project: Cloud Computing - Firebase Integration
- Date: November 2025
This project is created for educational purposes as part of a Cloud Computing course.
For issues or questions:
- Check the troubleshooting section above
- Review Firebase Console for errors
- Check Flutter logs:
flutter logs - Review app console output