App Uninstall Tracking

Track when a person uninstalls your Android or iOS app.

This feature is in private Beta and only available to select partners.

Android Implementation

Steps to Track App Uninstalls

  1. Integrate Firebase Cloud Messaging
  2. Get FCM Server Key
  3. Add Uninstall Tracking to your App
  4. Turn on Uninstall Tracking in the App Dashboard

Requirements

Firebase Cloud Messaging Integration

  1. Create a Firebase Project
    • Create a Firebase project in the Firebase console, if you don't already have one. Click Add project. If you already have an existing Google project associated with your mobile app, select it from the Project name drop down menu. Otherwise, enter a project name to create a new project.
    • Follow the remaining setup steps and click Create project, or Add Firebase if you are using an existing project, to begin provisioning resources for your project. This typically takes a few minutes. When the process completes, you will be taken to the project overview.
  2. Add your Android App to Firebase Cloud Messaging
    • Go to the Firebase console and navigate to left menu Grow > Cloud Messaging. In the dashboard, click android icon to add an app to get started. Then follow the setup steps. If you're importing an existing Google project, this may happen automatically and you can just download the config file.
    • When prompted, enter your app's package name. It's important to enter the package name your app is using; this can only be set when you add an app to your Firebase project.
    • During the process, you'll download a google-services.json file. You can download this file again at any time. Move the google-services.json file you just downloaded into your Android app module root directory.
  3. Add the Firebase Cloud Messaging SDK to your App
    • Add rules to your root-level build.gradle file, to include the google-services plugin and the Google's Maven repository:
      buildscript {
        // ...
        dependencies {
          // ...
          classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
        }
      }
        
      allprojects {
        // ...
        repositories {
          // ...
          google() // Google's Maven repository
        }
      }
    • In your module Gradle file (usually the app/build.gradle), add the apply plugin line at the bottom of the file to enable the Gradle plugin:
      apply plugin: 'com.android.application'
      
      android {
        // ...
      }
      
      dependencies {
        // ...
        implementation 'com.google.firebase:firebase-core:16.0.1'
        implementation 'com.google.firebase:firebase-messaging:17.3.0'
      }
      
      // ADD THIS AT THE BOTTOM
      apply plugin: 'com.google.gms.google-services'

FCM Server Key Retrieval

  1. Go to Firebase console page and click on the cogwheel next to Project Overview in the left side navigation menu.
  2. Under the Cloud Messaging tab, you can see your Server Key in you Project credentials.
  3. Copy your Server key Token.

Implementing Facebook Uninstall Tracker in your Android App

  1. Add the following to your app's MainActivity.java file:
    • Import libraries:
      import com.facebook.FacebookSdk;
      import com.facebook.appevents.AppEventsLogger;
      import com.google.firebase.iid.FirebaseInstanceId;
      import com.google.firebase.iid.InstanceIdResult;
      import com.google.android.gms.tasks.OnSuccessListener;
    • Add following into onCreate() function in your MainActivity.java to upload current registration token:
      FirebaseInstanceId.getInstance().getInstanceId().addOnSuccessListener(
        new OnSuccessListener<InstanceIdResult>() {
          @Override
          public void onSuccess(InstanceIdResult instanceIdResult) {
            String deviceToken = instanceIdResult.getToken();
            AppEventsLogger.setPushNotificationsRegistrationId(deviceToken);
          }
        }
      );

Turn on Uninstall Tracking in the App Dashboard

  1. Go to your app's dashboard.
  2. Select Settings > Basic in the left side navigation menu.
  3. Scroll down to the Android Settings panel.
  4. Click the Track Android App Uninstalls switch to Yes.
  5. Add the FCM Server Key.
  6. Click Save Changes at the bottom right of your screen.

iOS Implementation

Steps to Track iOS App Uninstalls

  1. Enable Notifications
  2. Get APN Credentials
  3. Turn on Uninstall Tracking in the App Dashboard

Requirements

Enable Notifications

  1. Enable Push Notifications and Background Modes - Remote Notifications in the Capabilities of your Xcode project.
  2. Register remote notifications by adding the didFinishLaunchingWithOptions function in your AppDelegate.m or AppDelegate.swift.

    AppDelegate.m

    // For Objective-C in AppDelegate.m
    + (void)registerForRemoteNotifications 
    {
      if (@available(iOS 10.0, *)) {
        [[UNUserNotificationCenter currentNotificationCenter]
          requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound
          completionHandler:^(BOOL granted, NSError * _Nullable error) { }];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
      } else {
        [[UIApplication sharedApplication]
          registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil]];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
      }
    }
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      [self registerForRemoteNotifications];
      
      return YES;
    }

    AppDelegate.swift

    // For Swift in AppDelegate.swift
    func registerForRemoteNotifications() {
      if #available(iOS 10, *) {
        UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]){ (granted, error) in }
        UIApplication.shared.registerForRemoteNotifications()
      } else if #available(iOS 8, *) {
        UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil))
        UIApplication.shared.registerForRemoteNotifications()
      } else {
        UIApplication.shared.registerForRemoteNotifications(matching: [.badge, .sound, .alert])
      }
    }
    
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
      registerForRemoteNotifications()
    }
  3. Call setPushNotificationsDeviceToken in your AppDelegate.m or AppDelegate.swift to set and upload the device token.

    AppDelegate.m

    - (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
    {
        [FBSDKAppEvents setPushNotificationsDeviceToken:deviceToken];
    }

    AppDelegate.swift

    func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData)
    {
      FBSDKAppEvents.setPushNotificationsDeviceToken(deviceToken)
    }

Get Apple Push Notification Credentials

Login to https://developer.apple.com/ and gather information for Apple Push Notification Services.

  1. Find your Team Id and the Bundle Id you would like to track.
  2. Follow the Obtain an Encryption Key and Key ID from Apple instructions to obtain a 10-character string APNS Key ID and an Auth Key file with a .p8 file extension.

Turn on Uninstall Tracking in the App Dashboard

  1. Go to your app's dashboard.
  2. Select Settings > Basic in the left side navigation menu.
  3. Scroll down to the iOS Settings panel.
  4. Click the Track iOS App Uninstalls switch to Yes and select the Bundle Id you would like to track in the APNS Bundle Id dropdown menu. You may need to add Bundle ID in the previous field first.
  5. Add your APNS Key Id and Team Id.
  6. Click the APNS Auth Key file switch to Yes. You will be prompted to upload your Auth Key file. Make sure it is a valid file with .p8 file extension. After uploading, click Update to change the file or delete the file by turning the switch to Off.
  7. Click Save Changes button on the right of your screen.