Uninstall measurement
Overview
Set up uninstall measurement in Android apps using AppsFlyer SDK and Firebase Cloud Messaging.
Integrating uninstall measurement for Android
This document covers integration of uninstall measurement for the following scenarios:
- Apps that already use FCM
- Apps that don't use FCM.
The latest FCM client version can be found here.
Apps using FCM
To add uninstall measurement to an existing FCM integration:
in the onNewToken()
override, invoke updateServerUninstallToken
:
@Override
public void onNewToken(String s) {
super.onNewToken(s);
// Sending new token to AppsFlyer
AppsFlyerLib.getInstance().updateServerUninstallToken(getApplicationContext(), s);
// the rest of the code that makes use of the token goes in this method as well
}
Apps not using FCM
To integrate uninstall measurement:
- Download
google-services.json
from Firebase console. - Add the
google-services.json
to the app module directory - Add the following dependencies to your root-level
build.gradle
file:buildscript { // ... dependencies { // ... classpath 'com.google.gms:google-services:4.2.0' // google-services plugin } }
- In the app-level
build.gradle
, add the following dependencies:Note: If you receive a "Could not find method implementation()..." error, make sure you have the latest Google Repository in the Android SDK Manager.dependencies { // ... implementation 'com.google.firebase:firebase-messaging:23.0.3' implementation 'com.google.firebase:firebase-core:20.1.2' // ... }
- If you use FCM only to measure uninstalls in AppsFlyer, use
appsFlyer.FirebaseMessagingServiceListener
service, embedded in the SDK. This extends theFirebaseMessagingService
class, used to receive the FCM Device Token and callsupdateServerUninstallToken
. To addappsFlyer.FirebaseMessagingServiceListener
service to the app:Otherwise, override the<application <!-- ... --> <service android:name="com.appsflyer.FirebaseMessagingServiceListener"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT"/> </intent-filter> </service> <!-- ... --> </application>
FirebaseMessagingService.onNewToken()
method and callupdateServerUninstallToken
:@Override public void onNewToken(String s) { super.onNewToken(s); // Sending new token to AppsFlyer AppsFlyerLib.getInstance().updateServerUninstallToken(getApplicationContext(), s); // the rest of the code that makes use of the token goes in this method as well }
Note
If you use Proguard, make sure to add the following rule:
-dontwarn com.appsflyer.** -keep public class com.google.firebase.messaging.FirebaseMessagingService { public *; }
Testing Android uninstall measurement
The testing procedure described is valid for apps available via Google Play Store, pending, direct download, and via alternative app stores.
- The Uninstalls metric is available in the Overview dashboard.
- The list of users who uninstall the app is available in the uninstalls [raw-data reports].(https://support.appsflyer.com/hc/en-us/articles/209680773-Raw-data-reporting-overview#user-journey-report-availability).
To test Android uninstall measurement:
- Install the app.
- Uninstall the app. You can uninstall the app immediately after installing it.
- Wait for the uninstall to appear in the dashboard. This can take up to 48 hours.
Considerations
- The uninstall event registers within 24 hours as uninstall measurement is processed daily.
- If the app is reinstalled during this time, no uninstall event is recorded.
Overriding FCM's onMessageReceived
onMessageReceived
Overriding FCM's onMessageReceived
method and implementing your own logic
in it might cause uninstall push notifications to not be silent. This can impact the user experience. To prevent this, verify that the message contains af-uninstall-tracking
. See the following example:
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if(remoteMessage.getData().containsKey("af-uinstall-tracking")){ // "uinstall" is not a typo
return;
} else {
// handleNotification(remoteMessage);
}
}
Updated 4 days ago