Google Cloud Messaging (GCM) Migration to Firebase Cloud Messaging (FCM)

The Messaging and Mobile A/B testing features are not available for purchase and will be deprecated from the product on January 1st, 2022. Read more information on the Mixpanel blog.

At this time, Mixpanel’s Android push services leverage Firebase Cloud Messaging (FCM), as Google deprecated GCM and fully adopted FCM.

If it hasn't been done already, update your Mixpanel library to v5.5 and above, and change your Push Notification Code to continue using Mixpanel Push Notifications.

New Mixpanel Implementations

If you are implementing Mixpanel for the first time and are planning to use Android Push Notifications, then the migration does not affect you. You will implement using FCM.

Follow the instructions in the Android integration document to set up push notifications.

Move from GCM to FCM

Your users’ existing push tokens will work with your updated FCM API key if moving from GCM to FCM. This being said, you should update your GCM API Key on and use your FCM Server Key instead.

Access Google's migration guide here.

Update your Mixpanel Code

There are several updates that you need to make to an existing Mixpanel implementation in order to use FCM. Click here to view the release notes that outline the change.

How to remove GCM from an existing app

1. Open your AndroidManifest.xml file and remove the following permissions, as they are included in FCM by default:

<uses-permission android:name="" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="YOUR_PACKAGE.permission.C2D_MESSAGE" />

2. Remove the following tag from your AndroidManifest.xml file:

<receiver android:name=""
        android:permission="" >
                <action android:name="" />
                <action android:name="" />
                <category android:name="YOUR_PACKAGE" />

3. Remove GCM from your gradle dependencies:

dependencies {
      compile ''   // Remove this line

4. Remove any reference to People.initPushHandling(senderId):

MixpanelAPI.getInstance(this).getPeople().initPushHandling(SENDER_ID); // Remove this line

How to add FCM to your app

1. Add the following tag inside of your application tag in your AndroidManifest.xml file:

                 <action android:name=""/>

2. Add FCM to your gradle dependencies. Ensure that you have Google Services added:

buildscript {
     dependencies {
           classpath ''

dependencies {
     implementation ''

apply plugin: '

3. Place your google-services.json file into your Android project. You can obtain that file from your Firebase Console center.

4. The existing GCM Key is now called a "Legacy" token and it still can be used. That being said, Mixpanel suggests that you update your GCM API Key and use your FCM Server Key instead.

Did this answer your question?



Article is closed for comments.