Skip to contentSkip to navigationSkip to topbar
Page toolsOn this page
Looking for more inspiration?Visit the

Obtain FCM credentials


(new)

Beta

The Push Notifications API is part of the Twilio Communications API, currently available as a Private Beta product. The information contained in this document is subject to change. You acknowledge and agree that your use of the Twilio Communications API is subject to the terms of the Services in Private Beta(link takes you to an external page). This means that some features are not yet implemented and others may be changed before the product is declared as Generally Available. Private Beta products are not covered by the Twilio Support Terms or Twilio Service Level Agreement.

Request access to the private beta through the private beta access request form(link takes you to an external page).


Overview

overview page anchor

To send push notifications to Android devices and web browsers, you need Firebase Cloud Messaging (FCM) credentials. In this guide, you create a Firebase project and obtain the service account credentials required by the Twilio Communications API.



Create a Firebase project

create-a-firebase-project page anchor
  1. Navigate to the Firebase Console(link takes you to an external page).
  2. Create a new Google Cloud project or select an existing one. See the Firebase setup guide(link takes you to an external page) for detailed instructions.
    Welcome message for Firebase with option to create a new project and integrate Firebase products into an app.
  3. Register a new Firebase application. For detailed instructions, see the Firebase app registration guide(link takes you to an external page) .
    Add app button alongside push-demo-app under Explore section.

Generate service account credentials

generate-service-account-credentials page anchor
  1. In the Firebase Console, select your app from the project overview, then click the gear icon to open Settings .
    Firebase project overview with the gear icon for accessing app settings.
  2. Navigate to the Service accounts tab and ensure Firebase Admin SDK is selected.
    Project settings menu with tabs for General, Cloud Messaging, Integrations, and Service accounts highlighted.
  3. Click Generate new private key . This downloads a JSON file containing your credentials.
    Admin SDK configuration snippet with Node.js code example and a button labeled Generate new private key.

The credentials must be base64-encoded before you upload them to Twilio. Open a terminal in the directory where you saved the JSON file and run the following command.

cat YOUR_CREDENTIALS_FILE.json | base64 -b 0

Upload credentials to Twilio

upload-credentials-to-twilio page anchor

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

Upload FCM credentials using cURL

upload-fcm-credentials-using-curl page anchor
1
curl -X POST 'https://comms.twilio.com/preview/PushNotifications/Credentials' \
2
-H 'Content-Type: application/json' \
3
-d '{
4
"credentialType": "FCM",
5
"content": {
6
"privateKey": "YOUR_BASE64_ENCODED_KEY"
7
},
8
"appName": "YOUR_APP_NAME"
9
}' \
10
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN