アンインストール計測

概要

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:

  1. Download google-services.json from Firebase console.
  2. Add the google-services.json to the app module directory
  3. 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 
        } 
      }
    
  4. In the app-level build.gradle, add the following dependencies:
    dependencies {
        // ...
        implementation 'com.google.firebase:firebase-messaging:23.0.3'
        implementation 'com.google.firebase:firebase-core:20.1.2'
        // ...
    }
    
    Note: If you receive a "Could not find method implementation()..." error, make sure you have the latest Google Repository in the Android SDK Manager.
  1. If you use FCM only to measure uninstalls in AppsFlyer, use appsFlyer.FirebaseMessagingServiceListener service, embedded in the SDK. This extends the FirebaseMessagingService class, used to receive the FCM Device Token and calls updateServerUninstallToken. To add appsFlyer.FirebaseMessagingServiceListener service to the app:
    <application
       <!-- ... -->
          <service
            android:name="com.appsflyer.FirebaseMessagingServiceListener">
            <intent-filter>
              <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
          </service>
       <!-- ... -->
    </application>
    
    Otherwise, override the FirebaseMessagingService.onNewToken() method and call 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
    }
    

📘

注意

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.

Androidアンインストール計測のテスト方法:

  1. アプリをインストールします。
  2. Uninstall the app. You can uninstall the app immediately after installing it.
  3. Wait for the uninstall to appear in the dashboard. This can take up to 48 hours.

注意事項

  • 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

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-uinstall-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);
        }
    }

このページは役に立ちましたか?