Firestore with Kotlin

Simple Chat Application with Firestore — Part 1

Panduka Wedisinghe
3 min readDec 4, 2018

Hello folks, It has been a while since I posted my last article. In this article I am not going to discuss only about Kotlin and it’s magics. I am going to share how I implemented a simple chat application by using Firestore as the cloud storage. Let’s get the ball rolling.

What is Firestore

Cloud Firestore is flexible and scalable database for mobile, web and Server development. It is from Firebase and Google cloud platform.

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 Platform products, including Cloud Functions.

Why Firestore ?

The major reason for me to choose Firestore over Firebase is the learning curve. As I have done a few developments by using Firebase, I thought it is the right time to move forward and try out something new. It is more or less similar to the Firebase despite the fact that it has some features which are unique. FireStore is in Beta version yet. Prime feature is its document structure of holding data. You can read more about it on this link.

Start with Chat Application

Integrating Firestore into your Android Project is more or less similar to integrating Firebase.

  1. Go to Firebase console and create a new project
  2. In Database section, create Firestore database.

3. Select Security rules for Cloud Firestore. For this test project I have selected Start in test mode.

Set up your Development Environment

1.Add the Cloud Firestore Android library to your app/build.gradle file.

implementation 'com.google.firebase:firebase-firestore:17.1.3'

2. Go to Firebase console -> Project Overview which is on the top left hand corner. There you can select the platform which you want to add Firebase. Select Android as your development environment.

3. Add package name of the Android project that you have created and other optional fields according to your desire.

4. Firebase will generate the google-services.json file for you. Download the file and insert the file into your Android project as you are instructed to do. Ensure that you put the file into the same folder.

Now you have set up your Android project with Firestore. You are good to move forward with implementing chat application. In the next article, I will share how I built the simple chat application from scratch.

--

--

Panduka Wedisinghe

Android Developer /Software Engineer/Flutter Developer