-
Notifications
You must be signed in to change notification settings - Fork 1
1. Firebase Project Setup
-
You need to create a Firebase project for the first time. You may use existing Firebase project.
-
Go to Firebsae console, https://console.firebase.google.com/
- click
(+) Add project
menu. - enter project name. You can enter any name. ex) fireflutter-test
- click
Continue
button. - disable
Enable Google Analytics for this project
. You can eanble it if you can handle it.- click
Continue
button.
- click
- new Firebase project will be created for you in a few seconds.
- Tehn, click
Continue
button.
- Tehn, click
- click
-
Read Understand Firebase projects for details.
- Go to
Cloud Firestore
menu. - Click
Create Database
. - Choose
Start in production mode
. - Click
Next
. - Choose nearest
Cloud Firestore location
.- To know the right location, click
Learn more
.
- To know the right location, click
- Click
Enable
.
Firestore needs security rules to secure its data.
- Copy the rules from fireflutter firestore security rules
- Go
Cloud Firestore => Rules => Edit rules
and delete all the rules there and paste thefireflutter firestore security rules
. - Click
publish
.
This is optional.
If you wish to test Firestore security rules, you may do so with the following command.
Run Firebase emualtor first.
$ firebase emulators:start --only firestore
run the tests.
$ npm run test
$ npm run test:basic
$ npm run test:user
$ npm run test:admin
$ npm run test:category
$ npm run test:post
$ npm run test:comment
$ npm run test:vote
$ npm run test:user.token
$ npm run test:chat
There are three ways of updating Firestore security rules.
- Creating the index on Firebase console.
- Deploying the index from FireFluter Firebase.
- By clicking the URL on debug console while your are developing the app. And this may be the easiest from the other two.
- Create complex indexes like below.
- Go
Cloud Firestore => Indexes => Composite => + Create Index
- Go
Collection ID | Fields indexed | Query scope | Status |
---|---|---|---|
posts | category Ascending createdAt Descending | Collection | Enabled |
posts | category Ascending uid Ascending createdAt Descending | Collection | Enabled |
Example of adding Firestore indexes)
-
Or you can deploy Firestore index using CLI.
- You can clone the fireflutter firebase project and deploy firestore index.
- See Cloud Firestore Index Definition Reference for details.
-
Or, when you develop app, you may see a warning message related in security rules. And there will be a link to generate index.
- Enable Stroage in the project menu on firebase console.
- And add the following security rules.
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read: if true;
allow create: if request.auth != null;
allow delete: if resource.metadata.uid == request.auth.uid;
}
}
}
-
Do Android Setup and iOS Setup
-
Go to Authentication => (Click
Get started
menu if you see ) => Sign-in Method -
Click
Enable/Password
(without Email link). -
It is your choice weather you would let users to register by their email and password or not. But for installation test, just enable it.
-
Refer Firebase Authentication and FlutterFire Social Authentication for details.
- Buy Me a Coffee : https://www.buymeacoffee.com/faisalramdan17
- Contact us on Telegram : https://t.me/faisalramdan17
- Website: https://codingyourlife.id
- GitHub: https://github.com/faisalramdan17
- Facebook : https://www.facebook.com/codingyourlife.id
- Instagram: https://instagram.com/faisalramdan17 & https://instagram.com/codingyourlife.id
- LinkedIn: https://www.linkedin.com/in/faisalramdan17