Why and How to Use Google’s Firebase Suite: What Its Tools Can Do for You
The fundamental building blocks of Android app development can be whittled down to an Integrated Development Environment (IDE) and a device or emulator to run it on, and while these are enough to build an app, a host of other tools augment the developer experience, aiding the team behind the product to scale the product, improve the user experience, increase engagement and retention, and earn more.
Twitter is behind one of the most robust and reliable suites of these tools, Fabric, and Google has turned up the heat by transforming its realtime-database acquisition, Firebase, into a full-fledged mobile development suite. Firebase includes a wide variety of tools with straightforward implementations, and is an impressive offering from Mountain View, so have a look at what it can do and get started with implementing it in your product.
Despite Google Analytics providing a robust solution for insights on app usage and user engagement, a significant amount of professional developers choose to go the third-party route, opting for tools like Flurry and Fabric, for a variety of reasons. Firebase Analytics aims to fill that need
The simplest usage of Firebase Analytics logs installs, user attributes and a predefined set of events, with the documentation providing instructions for more advanced usage. Implementing an analytics suite is one of the most beneficial steps a developer can take, since it provides data about user behavior, target demographics, potential pitfalls, experience anomalies and usage heatmaps, aiding in decision making and marketing.
private FirebaseAnalytics mFirebaseAnalytics; mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
Most apps nowadays need to know the identity of the user, which allows them to store data unique of each one. This in turn allows the product to recognize the user, and provide a personalized and seamless experience across platforms. Authentication is usually a tedious process, given the varying preferences of userbase segments in terms of authentication provider.
Firebase Authentication encapsulates the process, authenticating via providers Google, Facebook and Twitter, through industry standards like OAuth 2.0 and OpenID, without the need for any server side code.
Simple usage using Google Authentication
compile 'com.google.firebase:firebase-auth:9.2.0' compile 'com.google.android.gms:play-services-auth:9.2.0'
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(getString(R.string.default_web_client_id)) .requestEmail() .build();
Firebase began as a real-time database product, which was acquired by Google and remained that way for a long time, before undergoing a subsequent course correction. Still the cornerstone of the suite, Firebase Realtime Database allows developers to store data in a NoSQL database as a JSON format, providing real-time syncing options to all connected devices and offline availability.
The free Firebase plan has a limit on simultaneous database connections and per second write counts, with the paid tiers offering much more flexibility. The model is extremely simple to implement, and provides a powerful tool with a few lines of code, with the console providing advanced options such as optional authentication.
FirebaseDatabase database = FirebaseDatabase.getInstance(); DatabaseReference myRef = database.getReference("message"); myRef.setValue("Hello, World!");
A large majority of apps require some amount of data to be stored on the cloud, be it images, audio or video. Most of these apps rely on private servers to deliver this data, and Firebase Storage aims to provide a simpler solution for this. Backed by Google Cloud Storage, the tool provides secure file uploads and downloads regardless of network quality, and provides a generous amount of space for even the free plan.
compile 'com.google.firebase:firebase-storage:9.2.0' compile 'com.google.firebase:firebase-auth:9.2.0'
FirebaseStorage storage = FirebaseStorage.getInstance();
Web hosting is a fundamental building block of the entire internet, and good free hosting is tough to find. Firebase Hosting aims to be the perfect solution to build and deploy web apps, as well as static content to a global CDN (Content Delivery Network) with ease. It also offers an option to park a custom domain on the hosted content, enabling developers to give friendly URLs to their web apps.
Firebase Hosting delivers SSL-configured storage and SSD caches, ensuring the content is loaded fast and securely. Deployment is done via a simple command line execution, with an option in the console to roll back to older versions.
npm install -g firebase-tools firebase init firebase deploy
User experience is perhaps the most pivotal metric when it comes to measuring an app’s success and growth, and providing a perfected user experience often requires a certain number of experiments to be carried out, with multiple options being explored to land on a right one. Earlier, this was carried out by successive updates and subsequent analytics gathering, but Firebase Remote Config takes away all the complications by allowing behavior and appearance changes sans any updates.
Remote config is carried out by the app reaching out to the server for a certain set of parameters, and if the user falls within the desired segment, retrieves the developer-defined values from the console, falling back to the default in-app values in case of any negative outcome
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
Test Lab (Blaze plan only)
Device farms acting as test labs have gained tremendous traction as of late, and despite the Google Play Developer Console providing a basic version of a test lab, Firebase Test Lab takes it up a notch, automatically providing one-click deployment to a variety of devices and device configurations. The results include logs, screenshots and screen recordings of execution and crashes, allowing developers to identify and fix potential bugs ahead of a release, after robust testing on the devices.
The Test Lab is only available on the pay-as-you-go Blaze plan, with testing priced at $5/device hour. The process can be fired up from Android Studio itself, and integrates well with CI (Continuous Integration) setups.
Crash reporting on Android has experienced a fate similar to analytics, with Crashlytics being the widely popular solution that most developers opt for. However, Firebase Crash Reporting is Google’s play in the space, since it is a critical area when it comes to scaling apps, often being a make-or-break factor.
Firebase Crash Reporting automatically reports crashes by simply adding the library to the Gradle build script, sorting and grouping errors based on severity, stack traces, users affected, et al. The library also supports a more advanced implementation, that allows developers to log events leading up to the crash.
Formerly known as C2DM (Cloud to Device Messaging), Google’s cloud messaging service has undergone yet another nomenclature shift, shedding its Google Cloud Messaging moniker to become Firebase Cloud Messaging. The service allows developers to send small amounts of data to devices at no cost, whether it be for a notification, instant messaging, or sync information.
A basic implementation involves merely adding the library to the Gradle build script, allowing developers to send basic push notifications to devices. More advanced implementations include message receive handling, device to cloud replies, etc.
Dynamic links are smart URLs that can open different content based on the platform they are activated upon. While far from a new concept, Firebase Dynamic Links allow targeted segments to increase acquisition, retention and lifetime value, and also work across app installs, hooking in to Google Play to prompt an install if the associated app is not present on the device.
Firebase Dynamic Links also include what was formerly known as Google AppInvites, allowing users to share an app with their circles, prompting an open if the app is installed and an install if the app is absent.
Simple Usage after creating a dynamic link in the Console
<intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:host="example.com" android:scheme="http"/> <data android:host="example.com" android:scheme="https"/> </intent-filter>
Google’s long-standing mobile advertising platform has come under the Firebase umbrella, linking up with Firebase Analytics to provide additional usage details. Existing AdMob configurations can remain intact, with integration hooking in seamlessly, the only requirement being a small linking process.
Want more posts like this delivered to your inbox? Enter your email to be subscribed to our newsletter.