Building rich messaging for your app might seem simple at first, but things can quickly escalate when you start to think about advanced features, edge-cases, and how to manage your chat infrastructure at scale. To overcome these challenges, you have several solutions available, but how do they compare?
Firebase evolved from a tool named "Envolve," which, interestingly enough, was built specifically to help developers code chat. Since then, Firebase has pivoted from a chat-specific tool to become a general-purpose development platform, comprised of numerous products, including a real-time database called Cloud FireStore. These generic Firebase products are "good at everything" but not great.
In short, to build chat with Firebase, you need to define a FireStore database structure. When someone sends a message, you then create a database record and, being a real-time database, FireStore broadcasts an event to all subscribers in real-time. Here is an example message structure:
An example of a subscriber would be your app, which can then render these new chat messages.
This works pretty well because, typically, you do actually want to keep a record of most messages for message history, search, etc. However, what about ephemeral events? For instance, if you wanted to show a typing indicator - that would involve creating an isTyping structure (or similar) in your database and cleaning it up periodically. Similarly, you'll need to think about how to handle delivered indicators, read indicators, online presence, media messages, and other such features yourself.
In our view, the greater the dependency you take on Firebase, the more the benefits compound. For example, you could use Firebase Authentication to authenticate and manage users, FireStore for your data (including chat data), and Firebase Cloud Messaging to send push notifications. Because it's all the same platform, Firebase makes it natural for these products to communicate together with reasonable (not unlimited) flexibility.
Whereas Firebase is good at everything, CometChat Pro is an excellent developer tool for enabling chat.
In contrast with Firebase, CometChat Pro offers a chat SDK featuring numerous chat-specific functions and events. For example, you would send a message with sendMessage and subscribe with onMessageReceived.
As another example, when a user starts to type, you would call startTyping and subscribe by creating a typingListener. You don’t necessarily need to convey that someone “stopped” typing because CometChat Pro can figure that out heuristically. You see, being focused on chat allows CometChat Pro to do one thing, and do it very well.
With Firebase, you need to do much work to build a basic chat, including managing the database structure, transactions, encryption, access rules, and more. With CometChat Pro, most of the work has been done for you.
Another benefit of CometChat Pro is extensions. To date, CometChat Pro has nine available extensions and more on the way:
- Push notification
- SMS notification
- Email notification
- Message translation
- Thumbnail generation
- Sentiment analysis
- Human moderation
- Profanity filter
- Smart replies
- Link preview
- Image moderation
With extensions, we have anticipated the most common and natural "next steps" for your chat app. You know you need the basics - like messaging and “who’s online” presence. Advanced features that would generally require a lot of time and energy can now be added in no time with simple "turnkey" extensions.
CometChat Pro has a concept of a "CometChat user," by which you can store frequently-needed data like the user's name, username, avatar URL, and so on. That being said, CometChat Pro does not concern itself with authentication - to authenticate users, you will need to perform that logic on your own server (or using a third-party tool like Auth0) and generate a token for CometChat Pro to use. We wrote a tutorial about how to build a chat authentication server that makes it easy.
On reliability and security
When you base your app on a platform, you expect it to be completely reliable, secure, and compliant.
Firebase has been around for almost a decade, and being a development platform, many serious applications like The New York Times and todoist are built on Firebase. That being said, many customers have experienced frustration and disappointment with Firebase due to sporadic outages and reported security vulnerabilities. These issues likely didn't affect all applications, but it would be reasonable to assume these issues are going to be most prevalent in any real-time system like a chat.
CometChat was founded a couple years earlier in 2009, and since then, we have powered billions of conversations. While no platform is immune to downtime, staying in one lane and focusing only on chat affords us a more predictable environment in which to plan our failovers should anything go awry. CometChat Pro is completely GDPR compliant and secure.
Firebase offers three plans creatively named Spark, Flame, and Blaze:
Anticipating your monthly bill is tricky and may surprise you. That being said, you can reason that using the Flame plan, 100,000 daily document writes, and 10GB monthly bandwidth for $25 is reasonable. Of course, you will need to do much work yourself, which must be factored into your total cost.
CometChat Pro offers two plans named Metroid and Asteroid, plus you an also enroll on a custom plan:
Whether you are a solo-entrepreneur, growing start-up, or enterprise, CometChat Pro offers transparent pricing, so you'll always know what you'll pay.
I hope this comparison has helped highlight the key differences between CometChat Pro and Firebase. At the end of the day, there will be no better comparison than the one you and your team carry out independently. Of course, if you have questions or need help building your prototype/MVP with CometChat Pro, you can join our Slack group or get in touch - you may be surprised at how quick you receive response.