Skip to content

@patedit patedit released this Feb 20, 2019 · 30 commits to master since this release

GCM has been officially removed from the SDK. The following information is useful for existing and new Mixpanel customers:

How to remove GCM from an existing app

  1. Open your AndroidManifest.xml file an remove the following permissions since they are included in FCM already:
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<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" />
  1. Remove the following tag from your AndroidManifest.xml file:
<receiver android:name="com.mixpanel.android.mpmetrics.GCMReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="YOUR_PACKAGE" />
         </intent-filter>
</receiver>
  1. Remove GCM from your gradle dependencies:
dependencies {
      compile 'com.google.android.gms:play-services-gcm:10.0.1'   // Remove this line
      ....
}
  1. Remove any reference to People.initPushHandling(senderId) since it's no longer used:
MixpanelAPI.getInstance(this).getPeople().initPushHandling(SENDER_ID); // Remove this line

How to add FCM to your app

  1. Add the following tag inside your application tag in your AndroidManifest.xml file:
<application>
     ...
     <service
            android:name="com.mixpanel.android.mpmetrics.MixpanelFCMMessagingService"
            android:enabled="true"
            android:exported="false">
            <intent-filter>
                 <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
      </service>
     ...
</application>
  1. Add FCM to your gradle dependencies. You should already have Google Services added, but double check that's the case:
buildscript {
     ...
     dependencies {
           classpath 'com.google.gms:google-services:4.1.0'
           ...
     }
}

dependencies {
     implementation 'com.google.firebase:firebase-messaging:17.3.4' // Must be higher than 16.2.0
     ...
}

apply plugin: 'com.google.gms.google-services'
  1. Place your google-services.json file to your Android project. You can grab that file from your Firebase Console center.

  2. We suggest to update your GCM API Key on mixpanel.com and use your FCM Server Key instead. Notice that your existing GCM Key it's now called Legacy token and it is still supported.

  3. Enjoy!

Assets 2
You can’t perform that action at this time.