Firebase for your OutSystems mobile app

David Sousa
Truewind
Published in
6 min readDec 28, 2018

Why Firebase?

I’m sure everyone who builds a mobile app will want to know their users, what they do and how much time they spend on it.

Having this kind of information will allow you to make better decisions in order to expand your user base and to keep them happy with the app. Acquiring it, however, can be a hard task.

That’s when Firebase comes to the rescue. It was built with mobile apps in mind and comes packed with many products that provide us with ways to get to know our users.

Firebase features

Firebase comes with an Analytics tool which gathers information on the application usage and user engagement, through event reporting and user properties. It gives us insights that go from user acquisition to app interaction and user retention. Some cool features are:

  • Some events are automatically captured — such as app installation, app start or app removal. It also allows us to define our own custom events, with optional event parameters, to measure what fits our business needs, and use them on button clicks, screen views, etc.
  • User properties can be used to define audiences or user segments. These segments can be later on targeted with notifications or specific app configurations. We could, for example, pick only the users that are inactive for a period of time and send them a push notification to get them back in the app.

Firebase also comes with other useful products such as:

  • Crashlytics, a crash reporting tool, which gives us a detailed report on the app crashes and how many users it affected.
  • Performance monitoring, helping us to track down possible performance issues. It allows us to measure key interactions (such as login, data synchronization, etc) and to check how long they take on a variety of different conditions, such as app version, mobile phone brand, type of internet connection, operating system and so on.
  • Cloud messaging, giving us the possibility to define and send push notifications to users.
  • Remote configuration, which allows us to define configurations and apply them to a set of users. For example, we could target 10% of our user base and have them experience a new app theme. Joined with A/B testing, audiences and analytics, it proves to be a powerful tool to test the efficiency of new features on a subset of your user base.

This all sounds great, but what’s even better is that its base plan is free!

Now, an important question... How can I integrate my OutSystems mobile app with Firebase?

Our component

Well, we built the Firebase Mobile component and published it in the OutSystems Forge! It provides the integration with Firebase for both Android and iOS operating systems, while also including a server-side module responsible for sending push notifications through Firebase’s API.

We also added to the Forge a sample application showing some of our plugin’s features and how to use them. You can check it here.

Configuring Firebase may seem the hardest part, so that’s why I’m going to only focus on that for now. Feel free to follow this guide and configure the sample app with your own Firebase project in your OutSystems environment.

How to configure

So, first of all, go to the Firebase console and create a project if you don’t have one already.

Creating a Firebase project

Add a new Firebase app for each mobile operating system your app supports. Since OutSystems allows us to build native apps for Android and iOS, let’s add both. While adding each Firebase app, use the app identifier obtainable from Service Studio.

In the Firebase console, open the Android app wizard, register the app in the first step and download the configuration file in the second step. Keep the file — google-services.json — since we’ll be using it next. Skip the remaining steps.

Registering the Android app in Firebase

Similarly, register the iOS app and download the configuration file — GoogleService-Info.plist. Also, safely skip the remaining steps.

Registering the iOS app in Firebase

Now that you have both configuration files, let’s prepare them so that we can add them to the OutSystems app.

Add both google-services.json and GoogleService-Info.plist to a zip folder. Ensure that the folder is called google-services.zip and that it only contains both config files.

Creating a zip folder with both configuration files

Finally, open your app module in Service Studio and add the zip folder in the Resources tab. Make sure that:

  • The Name is “google-services.zip”
  • The Deploy action is “deploy to target directory”
  • The Target directory is the concatenation of “firebase.” with the app identifier. So, if your app identifier looks something like “com.example.myapp”, the target directory should be “firebase.com.example.myapp”.
Configuration files added in Service Studio

With the configuration done, you can now build the application and use Firebase Mobile’s actions in your code. When you install the app and open it, it’ll be successfully registered with Firebase.

Support to multiple environments

If you’re wondering why we have to configure the “target directory” of the configuration files to include the application identifier, that’s because we need to support having Firebase in a multiple environment scenario.

For example, if we have 3 environments (DEV, QA and PROD), and a different app identifier in each environment, we’ll also end up with a Firebase project for each environment.

In this case we’ll need to create 3 zip folders with the respective configuration files and add them in the Resources tab in the lowest environment (DEV).

Enabling Firebase in multiple environments

Afterwards, we can safely deploy our application to the upper environments with Lifetime.

The plugin will pick the correct zip folder when the app is being built and apply the right configurations to the app.

Final notes

It’s important to note that Firebase is constantly being improved and receiving new features. Also, the mobile ecosystem is an ever-changing world, with new OS versions almost every year. Our plugin will also continue to adapt to all the external changes.

If the article aroused your interest in this amazing tool, please visit the Firebase Mobile plugin page, which also includes some useful documentation, and the Firebase Mobile Sample, where you can test some features and take a look at the code.

If you have any doubt, feel free to ask a question in the forums.

To wrap it up, I would like to thank my Truewind team, the github repo which served as a base to our plugin, and finally you for reading the article!

--

--