Ubuntu Setup FCM

Kevin FOO
4 min readJul 7, 2020

--

Setting up Firebase Cloud Messaging (FCM) in Ubuntu Server 20.04 and later deploy to Firebase Hosting from scratch.

This setup works in
1. Windows (Edge, Chrome, Firefox)
2. macOS (Chrome, Firefox)
3. Android (Chrome, Firefox)

This setup does NOT work in
1. macOS (Safari)
2. iOS(Safari, Chrome, Firefox)

Create a new project
Give your project a name
Click [Continue]
Give this project a name in Google Analytics. Choose your desired region.
Project successfully created
Add a web app
Give your web app a name
Get the sample from Github
Choose cloud messaging for web
We will need the folder contents of messaging
Lets resume to step #3

It is a brand new AWS EC2 Ubuntu Server 20.04 so I’ll have to run these below.

sudo apt update
sudo apt upgrade -y
sudo apt install -y npm
sudo npm install -g firebase-tools
Login to Firebase after successfully installing Firebase tools
Run “firebase login” in tmux if you’re running Ubuntu server like me
Login with your Google account
Click [Allow]
Copy the URL
Use a different tmux session, curl the copied URL. Remember to add single quote before and after the URL.
Login successful.
Choose hosting
Choose the project created earlier

Now we clone the sample project earlier.

cd /tmp
git clone https://github.com/firebase/quickstart-js.git
cd quickstart-js/messaging
cp * ~/oofnivek-medium-fcm/

In the index.html, edit the “<YOUR_PUBLIC_VAPID_KEY_HERE>” with your web push certificate key pair. Below are the series of steps of how to get it.

Lastly deploy it to Firebase hosting

Now test if the setup was successful.

After clicking [Allow], this is the FCM registration token. Copy it.
Click [Send test message]
Paste the FCM registration token here
Successfully received the push notification

Next I’ll be writing up on how to send Firebase Cloud Messaging (FCM) push notifications using Bash curl.

< Back to all the stories I had written

--

--

Kevin FOO
Kevin FOO

Written by Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

No responses yet