Sending Android in-app notifications


Mixpanel allows you to create and send richer notifications that appear while your Android app is running. If you are using our in-app notifications product, there are 3 things you need to make sure of.

  1. Include the latest version of the Mixpanel Android library in your app
  2. Make sure you are identifying your users in the app.
  3. Create an in-app notification on the Notifications tab of the Mixpanel website.


The Mixpanel Android library automatically checks for notifications in the background, and will attempt to display them anytime an Activity is displayed. If you only wish to use mini in-app notifications, then no extra integration is necessary.

If you wish to use takeover notifications, then you must declare TakeoverInAppActivity in your AndroidManifest.xml file.

<activity android:name=""

For versions prior to 5.0.0 you should use and @style/com_mixpanel_android_SurveyActivityTheme instead.

The specified theme is a general Mixpanel default, so feel free to substitute your own theme better match the look and feel of your application.

Controlling when to show an in-app notification

You may not want the notifications to show everytime a new Activity is displayed. For example, if you have a game and only want to show a notification when a user accomplishes a goal, you need to turn off the automatic showing of notifications by adding the following option in the <application> section of your AndroidManifest.xml file.

<meta-data android:name=""
           android:value="false" />

To manually check if an in-app notification is available, you may call MixpanelAPI.getPeople().getNotificationIfAvailable(). This method will return an InAppNotification object if the Mixpanel library has received an in-app notification for the currently identified user, and null otherwise. You may then use this object to render your own in-app notification.

You can also call MixpanelAPI.getPeople().showNotificationIfAvailable() to allow the Mixpanel library to show an in-app notification for you.

Note that MixpanelAPI.getPeople().showNotificationIfAvailable() will not display a notification if there is already a notification showing, so it is safe to call this function at any location where you want to potentially display a notification.

Using profile properties

Just like emails, in-app notifications will replace content wrapped in {{}}. For example, if you add a Location property to your user profiles, you can send notifications like this:

Come and visit us at our {{ ${Location} }} office!

A user with a profile property Location: Asheville will get the following message:

Come and visit us at our Asheville office!
If some of your profiles have a value, but others don't, you can use a fallback value:

Come and visit us at our {{ ${Location} | fallback:"nearest" }} office!

Profiles without a Location property will receive this message:

Come and visit us at our nearest office!