Integrating Firebase for Mobile App Chats and Push Notifications

Not applicable for web templates if there is no chats

Introduction

Firebase which is owned by Google provide multiple set of features more specifically focused on Mobile app and gradually bringing new features for web apps as well. Having a glance the URL : https://firebase.google.com/ can tell you every list of features they offer. Apart from confidential notes, we use firebase to allow you to

  • Check your app stability and Performance using their Crashlytics
  • We use App Distribution to share pre-release built with you, so you can share with your team to test the app before it get’s published
  • It does bring you out of box features like Dynamic Links, Predictions, Cloud Messaging, etc.

Firebase done a good job of explaining each features through a short video on every page you navigate, so you will be educated if this is the first time you are using Firebase.

Video: Configuring Firebase

See how to configure stripe for your marketplace.

Step by Step

  1. Go to Firebase
  2. Signup for a free account using your gmail account (It is recommended to have one GmailID or GoogleApps email for all your signup like this)
  3. Create a new project as you see here fb-newproject
  4. Name your project fb-nameit
  5. As Google analytics comes on top of firebase and it’s free. Consider enabling to get free mobile app analytics fb-enablega
  6. You will not find anything like ist… but you need to create your Google cloud solution account as well fb-addgcp
  7. From here you can go to upgrade your billing option as Blaze plan is necessary fb-upgrade
  8. Choose Blaze plan which is pay as you go plan fb-blaze
  9. From here you can find the access control fb-users
  10. Add TradlyTeam email sent to you as owner fb-owner

Note: Blaze plan is mandatory to deploy push notification for chat messages

Downloading Android JSON

Downloading Android Plist Json from Firebase. Visit Project Settings > General > Find the JSON file in the body section. See the blue button as per the below screenshots.

Downloading Android Plist Json from FirebaseDownloading Android Plist Json from FirebaseDownloading Android Plist Json from Firebase

Applying Firebase Rules

Read below on how to create Realtime Database and apply realtime database rules.

  1. Navigate to your firebase project on the Firebase console and select Realtime Database under Build section from left menu.

    Setting up firebase rules
  2. Click “Create Database”

    Setting up firebase rules
  3. Select desired storage location which is close to your country and click ‘Next’.

    Setting up firebase rules
  4. Leave it in Locked Mode, click Enable.

    Setting up firebase rules
  5. Great! You have created Realtime Database successfully. Now let’s apply database rules. Select Rules tab and copy-paste below given rules and click Publish

{
  "rules": {
  "$env":{
      "users":{
         "$uid": 
         { 
           ".read": "auth != null"
         },
         ".write":"auth != null"       
  },
  "chats":{
   "$chatroom_id":{
    ".read":"auth != null && root.child($env+'/chats/'+$chatroom_id+'/users/'+auth.uid).exists()",
    ".write": "auth != null"
   }
  }
   }
}
}
Setting up firebase rules

Got questions?

No spam. You can unsubscribe at any time.