Obtaining FCM Credentials

Overview

To send push notifications to Android devices and web browsers, you need Firebase Cloud Messaging (FCM) credentials. This guide walks you through creating a Firebase project and obtaining the service account credentials required by the Twilio Communications API.

Prerequisites

Create a Firebase project

  1. Navigate to the Firebase Console.

  2. Create a new Google Cloud project or select an existing one. See the Firebase setup guide for detailed instructions. A screenshot showing Firebase project creation

  3. Register a new Firebase application. Check the app registration guide for detailed instruction. A screenshot showing Firebase app creation

Generate service account credentials

  1. Select your app, then click the gear icon to open Settings. A screenshot showing the app selection

  2. Navigate to the Service Accounts tab and ensure Firebase Admin SDK is selected. A screenshot showing the Service Accounts tab selected

  3. Click Generate new private key. This downloads a JSON file containing your credentials. A screenshot showing the private key generation button

Encode the credentials

The credentials must be base64 encoded before uploading to Twilio. Open a terminal in the directory you saved the file to and run:

cat your_filename.json | base64 -b 0

Replace your_filename.json with the actual filename of your downloaded credentials file.

Upload credentials to Twilio

Use the base64-encoded string as the privateKey value when creating your FCM credential:

curl -X POST 'https://comms.twilio.com/preview/PushNotifications/Credentials' \
--header 'Content-Type: application/json' \
--data '{
"credentialType": "FCM",
"content": {
"privateKey": "your_base64_encoded_key"
},
"appName": "your_app_name"
}' \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

Next steps