Skip to main content

Firebase

Setup

Let's configure Firebase for cloud messaging

  1. Navigate to https://firebase.google.com/ and sign to your existing account or sign up

  2. Create a new project and give it a name (e.g. ChatAI)

Firebase 1

  1. Press on continue

Firebase 2

  1. Select a google analytics account and press on Create project

Firebase 3

  1. We have to add both Android and iOS Apps. Let's start by adding the Android App. Press On the Android icon.

Firebase 4

  1. Type the package name and press on Register App.

Firebase 5

  1. Press on Download google-services.json and save it somewhere on your pc. Then press next till the end.

Firebase 6

  1. Go back to the project overview and press on the Apple icon.

  2. Type the apple bundle Id and press on Register App

Firebase 7

  1. Press on Download GoogleService-Info.plist and save it somewhere on your pc. Then press next till the end.

Firebase 8

  1. Go to your project files and add the previously downloaded json and plist files in steps 6 and 9 to the root project folder.s

Firebase 9

Realtime Database

  1. Go back to firebase, then to the project overview and download this json files Download

  2. Press on the Realtime Database and import the JSON file previously downloaded. This will import the necessary configuration of the app.

Firebase 10

  1. After successfully importing the configuration, let's explore the various configurable aspects of the application (In the next 3 images):

    1. Configuration:
    • Ads: In this section, you should input your Ad IDs, which you will generate in the next step.
    • Examples: This is where you can customize the content of the application's homepage, including text in three different languages.
    • Links: Here, you need to provide the links to your privacy policy and terms & conditions, which will be displayed within the app.
    • Product IDs: This section is where you should enter the subscription IDs after creating them in Apple Store Connect and Google Play Console.
    • Other: In this category, you should input the Apple App ID and Google Package Name to enable the App rating feature. Additionally, you can set the daily free message limit, which is initially set to 5 messages.
    1. Users: In this section, you can view all of the application's users and adjust their daily message limits. Please be cautious when removing a user from this list, as it may result in unintended behavior within the app.

This revision aims to make each section's purpose clearer and easier to understand.

Firebase 11

Firebase 12

Firebase 13

  1. Lastly, we have to update the database rules to be able to read and write to the database, copy the rules below and paste them as shown in the image below.
{
"rules": {
"configuration": {
".read": "true",
".write": "false"
},
"users": {
"$uid": {
".read": "true",
".write": "true"
}
}
}
}

Firebase 14