What is Firebase? Why and How to Setup Firebase?

By: Mayur
Updated: December 19th, 2016 | Technology: Cross Platform App Development
What is Firebase? Why and How to Setup Firebase?

What is Firebase?

Firebase is real-time database using cloud technology. That permits you to make application without server side coding and Rest APIs. All the database related action will be managed by firebase. So, you just need to focus on Front side. Rest of all back end side will be managed by firebase services like user management, User authentication, database management, Synchronization of data etc. We just need to do some settings on our website or mobile apps for using firebase services.

What are the advantages and disadvantages of Firebase cloud database?

Based on my ongoing R&D in December 2016 for firebase and its services. I have found some advantages and disadvantages of the firebase apps.

Firebase Pros:

  • First of all, If your app does run of a centralized DB, and it is used by a lot of users and update data frequently – than Firebase is more capable of handling the Real-Time data updates between devices.
  • Your data will be Stored in the cloud so it’s available anywhere.
  • Firebase is more suitable when you develop Cross-Platform API like Ionic, PhoneGap, Xamarin.
  • Finally, If you are storing lots of data, you don’t need to worry about hardware.

Firebase Cons:

  • First of all, Unless your app runs on one centralized database and your user base is vast than it’s overkill to update data.
  • Storage format of firebase is totally different from SQL, firebase uses JSON format so it’s not easy to migrate.
  • You won’t get any Reporting tools like standard SQL.
  • The cost of firebase is Limited to 50 Connections and 100mb of Storage.
  • If any small update comes from firebase side then you need to update your app and Republish it.
  • It is not possible to send push notification campaign using firebase.
  • Finally, Limited programming over server side.

When to use Firebase?

Firebase database is useful when your app requires simple authentication like email, facebook, google. And your product doesn’t require to provide API. app doesn’t have large data to display. And there is no use of a complex query. Your application has limited user base because firebase becomes costly when your user base is increased.

Here is the Best Examples:Simple chat App, Restaurant app, simple product listing app like Boneta, Chrono24.

When not to use firebase?

Firebase is not much useful when your user base is vast, products provide API, products has a large amount of data.

Then, there are no reporting tools available like SQL, and your app needs a complex query for the result than firebase is not suitable for your application. The Example is Amazon, Flipkart, Ubar.

Why firebase not feasible for Large application?

  • Firebase downloads all subtrees on load so it’s cause some performance issue.
  • The problem with data migration.
  • Complex query are not possible to write.
  • Not able to provide API for your product.
  • Small update in firebase needs to change and publish your app again.
  • No Reporting tools available so you don’t have a chance to check the performance of a query.
  • Rest API of firebase cannot be implemented quickly.
  • Custom code not supported by firebase.
  • Suitable for Time application only

What other choice do we have?

  • Ionic Cloud: IonicDB is a secure, cloud-hosted, real-time database. It utilizes a JSON storage so you’ll already be comfortable working with data, and of course, we’ve already integrated it with Ionic Auth, so the only thing you need to focus on is what matters. They have not declared pricing, During the private access period, IonicDB will be free.
  • Microsoft azure DocumentDB: Microsoft Azure DocumentDB is a NoSQL service for highly available, globally distributed apps. It provides native support for MongoDB wire protocol and Restful HTTP API.
  • Custom web app using MVC and SQL Server.
  • Meteor: Meteor is an open source web development tool using Node.js to build a real-time application as this feature is there in its core. With Meteor you can develop frontend, backend and a database for Cross-platform application. Like Android, iOSos and the web.Meteor is development tool using web framework and MongoDB as backend there is no restriction in programming you can build anything, you can host app only using Meteor.
  • Deployd (Deployd is built on **Node.js** and **MongoDB**)
  • MongoDB
  • Parse server: Parse server is open source and provide self-hosting or parse hosting and also there is no limit for local testing and deploying. Parse server totally supports custom code and Has huge relationship based database, It also allows to send push notification campaign, there is no restricted time limit and no file storage limit. It’s developed by facebook and suitable for General application.

Note : Parse server will be shut down on 28 January 2016 but parse open source version will be available. http://blog.back4app.com/2016/03/30/parse-open-source-is-moving-fast-but-still-has-some-features-to-be-opened-up-see-which/

Setup Requirement:

You need to install node.js in your PC. And you need to sign up with firebase and create your application and Setup firebase with your application.

How to setup firebase database in your mobile app?

  1. Include some javascript in your Index.html page.

    <script src=”https://cdn.firebase.com/js/client/2.2.4/firebase.js”></script>

    <script src=”https://cdn.firebase.com/libs/angularfire/1.2.0/angularfire.min.js”></script>

    <script src=”https://www.gstatic.com/firebasejs/live/3.0/firebase.js”></script>

  2. Initialize Firebase using below code in your Index.html page.

    <script>

    // Initialize Firebase

    // TODO: Replace with your project’s customized code snippet

    var config = {

    apiKey: “<API_KEY>”,

    authDomain: “<PROJECT_ID>.firebaseapp.com”,

    databaseURL: “https://<DATABASE_NAME>.firebaseio.com”,

    storageBucket: “<BUCKET>.appspot.com”,

    messagingSenderId: “<SENDER_ID>”,

    };

    firebase.initializeApp(config);

    </script>

  3. Include firebase reference in app.js file.

    angular.module(‘mychat’,[‘ionic’, ‘firebase’])

  4. Now you are ready for performing database action using firebase. The following code is for Insert data into firebase refer below code.

    var playersRef = firebase.database().ref(“players/”);

    console.log(“playersRef :” + playersRef);

    playersRef.set({

    Test Employee 1: {

    number: 3,

    age: 30

    },

    Test Employee 2: {

    number: 4,

    age: 27

    }

    });

Refer This link for More detail tutorial https://www.tutorialspoint.com/firebase/firebase_write_data.htm

Conclusion:

Firebase is realtime-database with facilitate online-offline sync and provide you all backend facility.

It’s not enough feasible for a Large application. And you can use it for a small application which has less amount of user base and data.

We are in Satva Solutions web and mobile app development company. Satva is a .Net based company and also working on Android, iOS, Windows phones, Ionic apps, Xamarin app, nopCommerce, Umbraco CMS, Orcard CMS, Rest API services, third party integrations, responsive design,  and much more.