Firebase Integration
a) Create a Firebase Account
Create a Firebase account and then gain access to your own Firebase Console. A Firebase account can host multiple Firebase Projects that can host multiple mobile apps.
b) Configure a Firebase Project
Create a mobile app project in Firebase for each app that you are planning to publish. If you are publishing to both iOS and Android, you will need to create separate apps in Firebase, since technically they are different apps.
If you want your Flutter app to run on both iOS and Android, then you need to create a different mobile app for each (in Firebase). Simply click on the “Add App” button.
After you select the platform (iOS or Android), you need to provide the app’s identifier. Depending on which Flutter template you’ve purchased. Find the correct identifier in the files you’ve downloaded
for Android, go to android/app/build.gradle and get the applicationId
for iOS, open the app in Xcode and locate the Bundle ID field in the project’s configuration
Once you have the bundle ID, just use it in Firebase, add your sha1 or sha256 key (For Mobile verification) and create the app.
Note:
Before you submit your app to the App Store or Google Play, you’ll need to update these bundle identifiers with your unique identifiers, since the app stores don’t allow duplicate application ids.
c) Enable Firebase Authentication
To enable Firebase Authentication, go to Firebase Console -> Authentication -> Sign-in Methods and enable the methods that you are going to support in your app. By default, our Flutter apps have integration with Email/Password, Phone, and Facebook.

For Facebook log-in, you’ll also need your Facebook App ID. You can add that later when you set up Facebook.
d) Enable Firebase Firestore
To allow the mobile app to read and write data to/from Firebase Firestore, set up the correct access permissions. To do that, just head over to Database -> Cloud Firestore and set the Rules for writes and reads to the public.
service cloud.firestore
{
match
/
databases
/
}
database
},
/
documents
{
match
/
{
document
=**
},
{
allow read, write: if true;
},
},
},
e) Enable Firebase Storage
If your mobile app needs access to Firebase Storage (e.g. for uploading photos and videos, for instance), you have to enable Firebase Storage, so that the functionality works properly. To enable it, just go to Storage in the left menu.
service cloud.firestore
{
service firebase.storage
{
match
/
b
/
{
bucket
}
/
o
{
match
/
{
allPaths
=**
}
{
allow read, write: if request.auth
!=
null
;
}
}
}
f) Link Firebase Account to Your Mobile App
Once you’ve created the app, Firebase will generate a configuration file name(for android google-service.json and for ios GoogleService-Info.plist). You have to add this file to your Flutter app. This is how the Flutter app can use your own Firebase backend. To do that, just download the configuration file and replace the existing mock files:
iOS:
Download the GoogleService-Info-plist file and override the
existing ios/NameOfApp/GoogleService-Info.plist file.

Android:
Download the google-service.json file and replace the
existing android/app/google-service.json file.

Add those files in all three apps as mentioned.
If you already have an app in Firebase, you can find and download this configuration file in Firebase Console -> Project Settings.
Run your brand new Flutter template, the mobile app will use your own Firebase backend, as opposed to our default one. Make sure you add all the tables and the required data in your Firebase so that the app will have items to display (e.g. Item categories, chat messages, etc.). To quickly test the Flutter firebase integration, try registering a new user and see if they show up in Firebase -> Authentication tab.
g) Enable SMS Phone Authentication
To enable SMS authentication with Firebase, there are a few things we need to configure, that will allow the app to send SMS to the users.
Enable Phone Authentication in Firebase In Firebase, go to Authentication -> Sign-in method -> Phone Authentication and check the Enable switch.
