Page tree
Skip to end of metadata
Go to start of metadata

How to enable the Firebase server on IM App:

Go to AdminCP > Apps > Installed > Instant Messaging > Settings and select "Firebase" at setting Select chat server

Then, configure the required Firebase Config Object setting. We will guide you to get the value when adding Firebase project which will be instructed below.

Also, you can configure Algolia App ID (Optional) and Algolia API Key (Optional) to support search messages. The instructions will be given later.

Setup Google Firebase App:

1. Add Firebase project

Go to Firebase console

Select Add Project if you don't have one

Go to App Dashboard, select Project Overview > Project settings 

In Your apps section click on icon </> to Add Firebase to web app

Add App nickname, then click Register App, then click Continue to console to back to Project Settings page

In Your Apps section, chose the app you just created, then click on Config option of Firebase SDK snippet. Copy all script code  and paste to Firebase Config Object setting in AdminCP > Apps > Installed > Instant Messaging > Settings area.

2. Enable Firebase Database

Back to Firebase App Dashboard, select Develop > Database. Then, right-click on Create Database. Select mode and click Enable

After enabling, you will redirect to database page. In that page, select tab Indexes and add 2 Composite indexes to Database by click on Create index manually. 

Then, configure fields as 2 screenshots below:
 

Indexes enable:

Go to Develop > Authentication, enable Sign-in method for Email/Password provider in your project to allow users access to the database, as the following screenshot:

Then, go to Database Rules tab and add the following database rules:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: 
      if request.auth.uid != null && request.auth.token.email.matches('^user_([0-9]+)@.*');
    }
  }
}

Rules table will be as the below image:

Now, you can start to use IM App with Firebase.

Setup Algolia to support search messages

Note: Without Algolia configure on IM App, users can only search for messages with prefix and case sensitive.

Go to Algolia App Manage, sign up if you don't have an account

Note: Algolia is pay to use, so you should check their pricing at Algolia Pricing

Go to your App Dashboard

Select Indices, create new Index with name im_chat


After Create Index, select menu API keys on left

  • Copy Application ID and paste to setting Algolia App ID on IM App
  • Copy Admin API Key and paste to setting Admin API Key on IM App

Now, users can search full-text messages with IM App and Firebase

  • No labels