Note: Use CTRL+click (on Windows and Linux) or CMD+click (on MacOS) for opening all the links in new tab.
Please open issues if anything goes wrong, I am happy to assist & resolve.
This is a Proof of Concept (POC) for It's Urgent Project for GSoC'24.
-
Working Demo & Apk (does not require any setup):
- Watch the working Demo Video here: https://youtu.be/__nhs4On2zI (1.5x speed recommended).
- Download this Android .apk for testing (You need to
allow installation from unknown source
when installing the app).
-
Running the App Using Flutter on your machine/device (Setup required):
- This public repo is clone of my private repo which contains all the firebase files, secrets & apis.
- This is a public repo, it does not contain any firebase functionlity.
- You need to add firebase project by following these simple instructions which only requires some clicks, copy & paste.
- For more important notes regarding this poc, see this section.
- You can also learn from these codelabs
-
Check your Flutter installation using:
flutter doctor -v
. -
Fork & clone this repo.
-
cd <this repo>
. -
Open in the Terminal/Android Studio/VS Code.
-
Install all plugins using:
flutter pub get
in the root folder of the project. -
For iOS only (Important for getting firebase notifications):
- If you are only using
com.example.<appName>
as bundle identifier, Firebase notifications will not work. So follow these steps before adding firebase to your app. - Right click on iOS folder -> Open in Xcode -> Runner -> Signing & Capabilities -> Enter some unique Bundle Identifier (like com.<your_unique_name>.<unique_appName> & press enter to check availability.
- Then again in VSCode or your editor go to ios/Runner/Info.plist.
- Change the CFBundleIdentifier to your own unique identifier like I did:
- If you are only using
-
Go to https://console.firebase.google.com/ to create a Firebase account.
-
If you haven't already, install the Firebase CLI (Use npm: recommended).
-
Also remove these lines from .gitignore file at the root folder of your project. Thesse lines were added by me to prevent git to track my firebase files:
/android/app/google-services.json
/ios/firebase_app_id_file.json
/ios/Runner/GoogleService-Info.plist
lib/firebase_options.dart
- Now move to Firebase section to add Firebase in your project.
- Follow these steps to add Firebase to this project.
- or, watch this YouTube Video.
- Go to Firebase console -> Click on your Project which you added to this flutter app.
- On the left side menu, click
Build
->Authentication
->Get Started
->Sign-in method
tab ->Anonymous
->Enable
(switch on) ->Save
.
- On the left side menu, click
Build
->Firestore Database
->Create Database
->Next
&Create
(With default options). - Once created, Select
Rules tab
-> Paste these rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// auth
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
Publish
.
- Click on Settings Icons next to
Project Overview
in the left side menu. - Click on
Project Settings
->Cloud Messaging tab
. - Click on
⋮
(three dots) next toCloud Messaging API (Legacy) Disabled
. - Click on
Manage Api in Google Cloud Console
. It will redirect to Google cloud console page. - Check your project name at the top and then click
enable
. - Once enabled, come back to the Firebase console to see whether it is enabled.
- Now copy the
Server key
. - Paste it in lib/secret.dart at
<paste your own key from firebase cloud messaging>
. - All done.
-
Navigate to the Apple developer page, and click Create a key on the Keys tab.
-
Enter the name for the key and check Apple Push Notifications services (APNs).
-
Download the key file, which has a .p8 file extension. Take note of Key Id & Team ID (At the top rigth corner):
-
In the Firebase console, navigate to the project's Project Settings and choose the Cloud Messaging tab.
- Upload the APNs key file for the iOS app in the Cloud Messaging tab.
- Enter the
APNs key ID
from the Cloud Messaging tab and theteam ID
, which can be found at the top right corner in the Apple membership center.
-
Again open the project in Xcode.
-
Click on Push Notifications.
-
Click on Background modes.
-
Now ensure that both the "Background fetch" and the "Remote notifications" sub-modes are enabled:
- All Done.
- Now you can connect physical device or simulator to run using
flutter run
. - If you have multiple devices connected, it will ask you to select one device.
- iOS simulators have problem showing notifications from Firebase, use physical iOS devices instead.
- This project uses Kotlin 1.8.0, which is required for app_settings plugin.
- In your android/settings.gradle
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
- In your android/settings.gradle
- In this poc, Notifications only shows when app is in the background mode.
- For the foreground mode, it requires extra functionality which I will implement using the flutter_local_notifications or awesome_notifications package during my GSoC period.
- It also does not check for device's DND mode. Full functionality during GSoC period.
- It is currently using Cloud Messaging API (Legacy) for sending notifications, which is deprecated, I will use Firebase Cloud Messaging API (V1) which is recommended in the full project during my GSoC period.
- It does not uses any other backend server, cloud functions to handle complex logics such as checking for dnd mode, notifying the sender about challenges etc. as required & mentioned in project page. All functionality will be implemented using Firebase cloud functions, which will also act as security layer for cloud firestore db.
- Currently Phone numbers are stored as plain numbers, I will implement functionality to store phone number data in encrypted mode using cloud functions.
- Flutter/Dart plugins used:
- firebase_core
- firebase_auth
- provider
- cloud_firestore
- flutter_contacts
- transparent_image
- app_settings
- firebase_messaging
- http