Push Notifications: Setting up FCM

Pusher can use FCM to deliver push notifications to your user’s Android applications on your behalf. When we deliver push notifications over FCM, we use your FCM credentials. You provide us with your credentials in the form of a Server Key. This page guides you through the process of getting a Server Key and providing it to Pusher to send Android push notifications.

You may already have an Android app which you would like to configure. If you just want to set up an app using WebSockets, see our Android Quick Start guide.

Getting Started

When Pusher sends a push notification through FCM, it authenticates using a Server Key provided by you. This section guides you through getting a Server Key from Firebase.

Each Server Key is associated with a Firebase project. To obtain a Server Key, you require a Firebase project. To send push notifications with this Server Key, Firebase Cloud Messaging must be enabled for that project.

Our guide depends on whether you already have a Firebase project you wish to use. If you do not yet have a Firebase project, follow the steps below using the Firebase Developer Console.

Creating a new Firebase Project

This section will guide you through creating a new Firebase project and obtaining a Server Key for it. For this, we will use the Firebase Developer Console.

screenshot of Firebase console

Click ‘Create New Project’. You will be asked for a project name and your region. Fill them in and click ‘Create Project’. You will then be taken to your page for that project.

Alternatively, as you can see above, there is an option to import an existing Google project. Follow that link and it should set one up for you.

Once you’re on the page for your project, skip to this section.

screenshot of Firebase console options for integration

Using an existing Firebase Project

If you have an existing Firebase Project, if you visit its project page, you will see in the top right a button to ‘Add App’.

existing Firebase project

Click ‘Add App’, and then follow the instructions below.

Get your google-services.json and Server Key

Click ‘Add Firebase to your Android app’ and you will be invited to register your package name. Once you fill this in, a google-services.json file should start downloading. Place this file under your app/ directory of your Android project.

screenshot of Firebase console options for integration

Afterwards, you will be taken to your app’s dashboard. On the card that represents your Android app, click the three dots on the top right, and choose ‘Manage’.

manage Firebase app

On the top navigation bar, you will see ‘Cloud Messaging’. Click it, and you should be taken to your Server Key 🎉.

your FCM key

Next, let’s upload the Server Key to the Pusher dashboard.

Give us your Server Key

You should have a Pusher app which you want to use push notifications with. If not, create a new Pusher app.

Visit dashboard.pusher.com and sign in with your Pusher account.

In the dashboard for your Pusher app, go to the Push Notifications tab.

On the Push Notifications tab, click the “Configure FCM” tab.

In the section “FCM API Key”, paste the Server Key you obtained earlier, and click “Save”.

You’re done! Next, let’s set up your Android app to receive some push notifications!

Have you tried using the search to find what you’re after? If you still have a question then get in touch with us and let us help you out.