Getting Started with Firebase

Last Updated: 29 Aug 2023

1. Create a Firebase Project 

1. Go to https://console.firebase.google.com/ 

2. Create a Project.

3. Enable/Disable Google Analytics (as per your requirement) 

4. Click on the Web button to add a Web App.

5. Next, Setup/Enable Firebase Realtime Database.

6. Go to Project Settings in Firebase Console.

7.
(1) Scroll down, then you will find your Web App.
(2) Click "Config".
(3) Click the Copy button to copy the Firebase Config data.


8. Now in Construct 3 editor, add the FirebaseV9 SDK plugin. (This plugin used is to connect to Firebase servers.)

9. Go to the Firebase SDK Plugin's Property Bar > SDK Configuration

9. Paste the Firebase Config data here.

10. For the Firebase Version, click the button below

2. Set Up "Firebase Authentication"

1. Go to Authentication > Sign-in method 

2. Enable the required Sign-in providers by clicking on the Pencil icon 

3. You must add an authorized domain. Go to Settings > Authorized domains >  Click on Add domain and enter preview.construct.net so that it will allow access from Construct 3 preview.

This is required during development, but it is suggested to remove this when you publish the app and no longer working on it. You can always add this again later on.

3. Set Up "Firebase Realtime Database"

1. Go to Database tab, scroll down to Realtime Database and click on Create Database 

2. Go to the "Rules" Tab, and replace everything with this text:

{

    "rules":

        {

            ".read": true,

            ".write": true,

        }        

}

⚠️WARNING: This will make your database public (insecure), so anyone can get or modify any data. These rules are preferred when you are still developing your app.

If you are going to publish your app, you will need proper Security Rules to protect your database. To do so, check out this Doc:📄Secure Your Firebase Project.

4. Set Up "Cloud Firestore"

1. Go to Cloud Firestore

2. Go to the "Rules" Tab, and replace everything with this text:

service cloud.firestore {

  match /databases/{database}/documents {

    match /{document=**} {

      allow read, write: if true;

    }

  }

}

⚠️WARNING: This will make your database public (insecure), so anyone can get or modify any data. These rules are preferred when you are still developing your app.

If you are going to publish your app, you will need proper Security Rules to protect your database. To do so, check out this Doc:📄Secure Your Firebase Project.

And done! You are now ready to start with your Construct 3 project! 

Try out some Example C3Ps to get started with your own project.

5. Getting Started with Construct 3 Editor

1. In the Firebase SDK plugin, Enable the Firebase Services you need in your project

2. Add the Firebase plugins you need in your project.

3. After adding a Firebase Plugin, for each of the Firebase plugins, you need to "Choose SDK Object" from the Properties.


(As it is possible to include more than one Firebase Project SDKs in one Construct 3 project, you must select an SDK object for each Firebase plugin.

Example as to how you can include two or more Firebase Projects into one Construct 3 project is provided in the Examples of your purchased package)

3. It is recommended to keep the First Layout almost empty and dedicated to the loading of Firebase SDK.
Once Load is successful, go to the next layout, and start making your rest of the game from there.
Go to the EventSheet of your First Layout.
Now this event below is the safest way to know that your Firebase SDK has been Loaded successfully.

(This is just a precaution to prevent any other Firebase action to trigger before Firebase SDK has been loaded successfully. Otherwise calling actions before a successful load might cause errors to freeze the game.)

4. Now you are ready to start with the rest of the Firebase plugins from the next Layout.

Have a look at some Examples provided in the package you purchased to for more guidance.

Download this C3 Project File to see how a recommended Project should look like

Debugging

Debugging is very important and helps make Development much easier. While developing, it is suggested to enable debugging.

To know how, read this Doc -📄Debugging


How much does Firebase charge for its services?

Have a look at the Firebase Pricing Plans before getting started: https://firebase.google.com/pricing


Which Database Service should you use?

Firebase provides two Database Services: Cloud Firestore and Realtime-Database.

See a full list of comparison to see what works best for you: https://firebase.google.com/docs/database/rtdb-vs-firestore


Some Important Links