Firebase legacy API to HTTP v1 migration guide

Last modified by Félix Olart on 2024/05/14 11:33

On June 20, 2023, Google announced the deprecation of the legacy FCM API, slated for permanent shutdown in June 2024. All applications and Flexisip instances relying on this service to send push notifications to Android devices must transition to the new HTTP v1 API to prevent service disruptions. This guide is designed to assist you in migrating your existing Flexisip configurations to integrate with the new FCM API.

Update and configure Flexisip

1. Install bc-flexisip-2.3.4-0.pre.36+0d5e7a13 or a later version (available via the 'hotfix' repository).
 

For centOS 7

As there are no yum packages available to install python3 version of the google-auth and requests python packages, we ask you to manually install them using pip3.

2. Generate a private key file for your service account:

  1. In the Firebase console, open Settings > Service Accounts.
  2. Click Generate New Private Key, then confirm by clicking Generate Key.
  3. Securely store the JSON file containing the key.

3. Deploy the JSON private key on each Flexisip host intended for sending push notifications with Firebase. For example, the file can be directly saved in the /etc/flexisip directory.

4. Edit your flexisip.conf file:

        Given that you already have a functioning Firebase setup, you should have something similar to this:

[module::PushNotification]

# Enable push notification for Android devices.
# Default: true
firebase=true

# List of pairs of <Firebase Project Number>:<Firebase Cloud Messaging
# API (Legacy) Server Key> for each Android project that supports
# push notifications.
# Default: 
firebase-projects-api-keys=123456789123:<api_key>

        Simply configure the firebase-service-accounts parameter by providing the project ID (123456789123 in this example) and the absolute path to your private key. Ensure that the firebase-projects-api-keys parameter is commented out.

[module::PushNotification]

# Enable push notification for Android devices.
# Default: true
firebase=true

# List of pairs of <Firebase Project Number>:<Firebase Cloud Messaging
# API (Legacy) Server Key> for each Android project that supports
# push notifications.
# Default: 
#firebase-projects-api-keys=123456789123:<api_key>

# List of pairs of <Firebase Project Number>:<Path to service account
# json file> for each Android project that supports push notifications.
# Default: 
firebase-service-accounts=123456789123:/etc/flexisip/<private_key>.json

# Represents the time in seconds to execute the access token refresh
# operation just before the current access token expires. This parameter
# is used to control overlapping access token lifetimes.
# Default: 300
#firebase-token-expiration-anticipation-time=300

# Default interval in seconds to execute the access token refresh
# operation in the event that the access token has not been successfully
# obtained.
# Default: 60
#firebase-default-refresh-interval=60

 5. Restart the Flexisip proxy; there's no need to restart other Flexisip components :

(bash)# systemctl restart flexisip-proxy

Update your google-services.json file within your Android application

While Google has not officially announced it, we advise updating your google-services.json file in your Android project.

1. Obtain a new version of the google-services.json file from your Firebase console. Refer to https://firebase.google.com/docs/android/setup#add-config-file.

2. Save the file in your Android project at <PROJECT_ROOT>/app/google-services.json.

3. Publish a new release of your application.