2. Firebase
Firebase is a product of Google which helps developers to build,
manage, and grow their apps easily. It helps developers to build their apps
faster and in a more secure way. No programming is required on the
firebase side which makes it easy to use its features more efficiently. It
provides services to android, ios, web, and unity. It provides cloud
storage. It uses NoSQL for the database for the storage of data.
is a powerful platform for your mobile and web application. Firebase can
power your app’s backend, including data storage, user authentication,
static hosting, and more. With Firebase, you can easily build mobile and
web apps that scale from one user to one million.
3. Brief History of Firebase:
• Firebase initially was an online chat service provider to various websites
through API and ran with the name Envolve.
• It got popular as developers used it to exchange application data like a
game state in real time across their users more than the chats.
• This resulted in the separation of the Envolve architecture and it’s chat system.
• The Envolve architecture was further evolved by it’s founders James
Tamplin and Andrew Lee,to what modern day Firebase is in the year 2012.
• In April 2012, Firebase was created as a separate company that provided
Backend-as-a-Service with real-time functionality.
• After it was acquired by Google in 2014, Firebase rapidly evolved into the
multifunctional behemoth of a mobile and web platform that it is today.
5. Build better apps
Firebase lets you build more powerful, secure and scalable apps, using world-class
infrastructure using:
1. Cloud Firestore: is a flexible, scalable database for mobile, web, and server
development from Firebase and Google Cloud Platform. It is a NoSQL document
database that lets you easily store, sync, and query data for your mobile and web apps
— at a global scale.It’s supporting for Android, iOS and Web Platform.
2. ML Kit: is a mobile SDK that brings Google’s machine learning expertise to Android and
iOS apps in a powerful yet easy-to-use package. Whether you’re new or experienced in
machine learning, you can implement the functionality you need in just a few lines of
code. There’s no need to have deep knowledge of neural networks or model
optimization to get started. On the other hand, if you are an experienced ML developer,
ML Kit provides convenient APIs that help you use your custom TensorFlow Lite models
in your mobile apps. It’s supporting for Android and iOS Platform.
3. Cloud Functions: for Firebase lets you automatically run backend code in response to
events triggered by Firebase features and HTTPS requests. Your code is stored in
Google’s cloud and runs in a managed environment. There’s no need to manage and
scale your own servers. It’s supporting for Android, iOS, C++, Unity and Web Platform.
6. Build better apps Cont.
4. Authentication: provides backend services, easy-to-use SDKs, and ready-made UI libraries to
authenticate users to your app. It supports authentication using passwords, phone numbers,
popular federated identity providers like Google, Facebook and Twitter, and more. It’s
supporting for Android, iOS and Web Platform.
5. Hosting: is production-grade web content hosting for developers. With a single command, you
can quickly deploy web apps and serve both static and dynamic content to a global CDN
(content delivery network). You can also pair Firebase Hosting with Cloud Functions to build
and host microservices on Firebase. It’s supporting only Web Platform.
6. Cloud Storages: is for object storage service built for Google scale. The Firebase SDKs for Cloud
Storage add Google security to file uploads and downloads for your Firebase apps, regardless
of network quality. You can use our SDKs to store images, audio, video, or other user-
generated content. On the server, you can use Google Cloud Storage, to access the same files.
It’s supporting for Android, iOS, C++, Unity and Web Platform.
7. Real-time Database: is a cloud-hosted NoSQL database that lets you store and sync between
your users in real-time. The Real-time Database is really just one big JSON object that the
developers can manage in real-time. It’s supporting for Android, iOS, C++, Unity and Web
Platform.
7. Improve app quality
• Firebase gives you insights into app performance and stability, so you can channel your
resources effectively using:
1. Crashlytics: is a lightweight, real-time crash reporter that helps you track, prioritize, and
fix stability issues that erode your app quality. Crashlytics saves you troubleshooting
time by intelligently grouping crashes and highlighting the circumstances that lead up
to them. It’s supporting for Android and iOS Platform.
2. Performance Monitoring: is a service that helps you to gain insight into the
performance characteristics of your iOS and Android apps. You use the Performance
Monitoring SDK to collect performance data from your app, and then review and
analyze that data in the Firebase console. Performance Monitoring helps you to
understand where and when the performance of your app can be improved so that you
can use that information to fix performance issues. It’s supporting for Android and iOS
Platform.
3. Test Labs: is a cloud-based app-testing infrastructure. It provides a large number of
mobile test devices to help you test your apps. It’s supporting for Android and iOS
Platform.
8. Grow your business
• Firebase helps you grow to millions of users, simplifying user engagement and retention using:
1. In-App Messaging: helps you engage users who are actively using your app by sending them
targeted and contextual messages that nudge them to complete key in-app actions — like
beating a game level, buying an item, or subscribing to content. It’s supporting for Android and
iOS Platform.
2. Google Analytics: for Firebase is a free app measurement solution that provides insight on app
usage and user engagement. At the heart of Firebase is Google Analytics for Firebase, a free
and unlimited analytics solution. Analytics integrates across Firebase features and provides you
with unlimited reporting for up to 500 distinct events that you can define using the Firebase
SDK. Analytics reports help you understand clearly how your users behave, which enables you
to make informed decisions regarding app marketing and performance optimizations. It’s
supporting for Android, iOS, C++ and Unity Platform.
3. Predictions: applies machine learning to your analytics data to create dynamic user segments
based on the predicted behavior of users in your app. These predictions are automatically
available for use with Firebase Remote Config, the Notifications composer, Firebase In-App
Messaging, and A/B Testing. You can also link your app’s Predictions data to BigQuery so you
can get daily exports that you can further analyze or push to third party tools. It’s supporting
for Android, iOS, C++ and Unity Platform.
9. Grow your business Cont.
4. A/B Testing: helps you optimize your app experience by making it easy to run, analyze, and scale product and
marketing experiments. It gives you the power to test changes to your app’s UI, features, or engagement campaigns
to see if they actually move the needle on your key metrics (like revenue and retention) before you roll them out
widely. It’s supporting for Android, iOS, C++ and Unity Platform.
5. Cloud Messaging(FCM): provides a reliable and battery-efficient connection between your server and devices that
allows you to deliver and receive messages and notifications on iOS, Android, and the web at no cost.
6. Remote Config: essentially allows us to publish updates to our users immediately. Whether we wish to change the
color scheme for a screen, the layout for a particular section in our app or show promotional/seasonal options —
this is completely doable using the server side parameters without the need to publish a new version. It’s
supporting for Android, iOS, C++ and Unity Platform.
7. Dynamic Links: With Dynamic Links, your users get the best available experience for the platform they open your
link on. If a user opens a Dynamic Link on iOS or Android, they can be taken directly to the linked content in your
native app. If a user opens the same Dynamic Link in a desktop browser, they can be taken to the equivalent content
on your website. It’s supporting for Android, iOS, Web, C++ and Unity Platform.
8. App Indexing: gets your app into Google Search. If users have your app installed, they can launch your app and go
directly to the content they’re searching for. App Indexing reengages your app users by helping them find both
public and personal content right on their device, even offering query autocompletion to help them more quickly
find what they need. If users don’t yet have your app, relevant queries trigger an install card for your app in Search
results. It’s supporting for Android and iOS Platform.
10. Realtime Database
• is a cloud-based NoSQL database that manages your data at the
blazing speed of milliseconds. In simplest term, it can be considered
as a big JSON file.
• Store and sync data with our NoSQL cloud database. Data is synced across
all clients in realtime, and remains available when your app goes offline.
• The Firebase Realtime Database is a cloud-hosted database. Data is stored
as JSON and synchronized in realtime to every connected client. When you
build cross-platform apps with our Apple platforms, Android, and
JavaScript SDKs, all of your clients share one Realtime Database instance
and automatically receive updates with the newest data.
11. Cloud Firestore:
• Cloud Firestore is a flexible, scalable database for mobile, web, and
server development from Firebase and Google Cloud.
• Like Firebase Realtime Database, it keeps your data in sync across
client apps through realtime listeners and offers offline support for
mobile and web so you can build responsive apps that work
regardless of network latency or Internet connectivity.
• Cloud Firestore also offers seamless integration with other Firebase
and Google Cloud products, including Cloud Functions.
12. Creating a Firebase project
First step create an account at https://firebase.google.com/
18. •Get your flutter project
Android Package Name.
•Your package name is
generally the applicationId
in your app-level
build.gradle file
•android/app/build.gradle
android {
namespace
"com.maz.myflutterapp01"
compileSdkVersion
flutter.compileSdkVersion
ndkVersion
flutter.ndkVersion
19. • Move your
downloaded google-
services.json file
• into your module
(app-level) root
directory.
• android/app/
20. • Skip the next Step and continue
to the console
21. • Step 2: Add the following in the AndroidManifest.xml file, in the
manifest -> application section
• android/app/src/main/AndroidManifest.xml
<meta-data
android:name="firebase_messaging_auto_init_enabled"
android:value="false" />
<meta-data
android:name="firebase_analytics_collection_enabled"
android:value="false" />
</application>
</manifest>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
22. • Step 3: Don’t add plugin { … }
• As per the Firebase docs, you need to add plugin { … } in gradle.build but you
shouldn’t add that.
• Instead, add classpath “com.google.gms:google-services:4.3.13” in
android/build.gradle file as shown in the image below.
• Upgrade the Kotlin to the appropriate version if you get any related error
24. • Step 4: Update android/app/build.gradle file
• Add apply plugin: ‘com.google.gms.google-services’ as shown in the
image below
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"
}
25. defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.maz.myflutterapp01"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id
applicationId "com.maz.myflutterapp01"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-config
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
• Add multiDexEnabled true in android -> defaultConfig section
26. • Add implementation platform(‘com.google.firebase:firebase-bom:32.7.0’) in
dependencies, this will take care of version compatibility of all the Firebase
packages
• Add implementation ‘com.google.firebase:firebase-analytics’
• Then add the package that your app needs, for instance, if it requires Firebase
Messaging (FCM), add implementation ‘com.google.firebase:firebase-
messaging’
flutter {
source '../..'
}
dependencies {}
flutter {
source '../..'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:32.7.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-messaging'
}
27. Now run your APP To make sure that there are no
mistakes and it’s connected it’s connected
34. Creating collections and inserting data
firebase_core:
firebase_auth:
cloud_firestore:
random_string:
fluttertoast:
permission_handler:
35. • Start by creating a new dbfirebase.dart
• Then will create a class called dbfirebase.dart for handling all the
database queries
import 'package:cloud_firestore/cloud_firestore.dart';
class Databasemethods{
}
36. • Then will create our first function addData() for creating and inserting
clollection
import 'package:cloud_firestore/cloud_firestore.dart';
class Databasemethods{
Future addData(Map<String, dynamic> DoctorsInfoMap, String id)async{
return await FirebaseFirestore.instance
.collection("lecturer")
.doc(id)
.set(LecInfoMap);
}
}
37. • Create a form with the following texfields
var _formKey = GlobalKey<FormState>();
TextEditingController lecName=new TextEditingController();
TextEditingController lecPhNo=new TextEditingController();
TextEditingController lecCol=new TextEditingController();
TextEditingController lecDept=new TextEditingController();
Databasemethods dbobj=new Databasemethods();
39. • Also before running e should initialize the flutter project
void main() async{
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());
}
40. • And before you run make sure your app has the permission to access
the internet.
• By editing android/app/src/main/AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
<application
41. • Before running we should run the following commands
• Flutter clean
• Fluter run
• Then add minSdkVersion 21 the build.gradle in the app level as the
following