Push Notifications: Setting up FCM
New to Push Notifications?
Go to the newer version: Pusher Beams.
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.
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.
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.
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.
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’.
Click ‘Add App’, and then follow the instructions below.
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.
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’.
On the top navigation bar, you will see ‘Cloud Messaging’. Click it, and you should be taken to your Server Key 🎉.
Next, let’s upload the Server Key to the Pusher dashboard.
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!