[Firebase Mobile] Push notification configuration guide

Forge Component
Published on 17 Jul by David Sousa
15 votes
Published on 17 Jul by David Sousa

In order to configure push notifications, follow the next steps:

1. Firebase configurations

To send push notifications with the Firebase's API you'll need to send a token in the request header. In order to obtain this token, access the Firebase project's console and open the Cloud Messaging settings:

  1. Head to your Firebase project's console.
  2. Click on the side menu's cogwheel, then select Project Settings.
  3. Click on the Cloud Messaging tab.
  4. Save the token correspondent to the Server key found under Project credentials

To send notifications to iOS devices you'll need to connect our app with Apple Push Notification service (APNs) by uploading either the APNs authentication key or APNs certificates. The configuration with APNs authentication key is recommended since it's the most current method for sending notifications in iOS. You can upload these files in the Cloud Messaging settings:

  1. Go to the Cloud Messaging tab in the Project Settings menu.
  2. Upload the authentication key or certificates under iOS app configuration.

2. OutSystems setup - mobile app

In your mobile app you'll need to run the plugin action InitCloudMessaging in:

  • the ApplicationReady system event (if there's already a user logged in) and

  • after the Login action.

It's also needed to run the action UnregisterDevice after logging out.

If you want to handle the push notifications while your users have their app open (in the foreground) you'll have to drag the FirebaseCloudMessaging web block to the required screens. We usually choose to put it in a Layout web block since that way we guarantee it'll be present in all screens.

3. OutSystems setup - server side

In your back-end you'll be using the action SendNotificationToUser, which requires the following inputs:

  1. FCMServerKey - the token you obtained from the Firebase Console in the first steps of this guide
  2. ApplicationId - recommended to use the value obtainable from the OutSystems action GetEntryEspaceName since that's the value used to register the devices when running the action InitCloudMessaging
  3. UserId - the user identifier of the user that'll receive the push notification
  4. Title - the title of the notification
  5. Body - the body of the notification

Remember that you can also test push notifications by using the Firebase Console or external tools, such as Postman, to call the API directly. Here is a link to a Postman collection that already has a template for sending push notifications for Android and iOS.


Thanks for the guide. How does one go about customizing the notification icons to be different from the launcher icons when using this app?


May I know where to find the SendNotificationToUser server action? Which plugin? Thanks

Why would you unregister the device on logout?  Would that not stop the device from receiving push notifications?


That could be a valid business reason. If a user logs out of any of my business apps that I, as business data owner, don't want them to receive push messages with potential confidential information. For a B2C app without logon (like a project app to inform your stakeholders/neighborhood) you could choose to only register the device since the message will then be public by definition.