Integrate iOS uninstall measurement into an app

At a glance: Setup uninstall measurement in iOS apps by integrating Apple Push Notification Service (APN) into the app.

iOS uninstall measurement

iOS uninstall measurement is available by adopting APN in the app.

Considerations:

  • APN reports in real-time when a user removes an app only if at least eight days have passed since the install. This means that iOS uninstall data is available only after day 8.
  • Measurement is not possible for users who reject Push Notification permissions.
  • As per Apple's announcement, beginning with iOS 15, “Background pushes will only be delivered if the app has been used in the foreground in the past few weeks.”

iOS app requirements:

  • iOS 13+
  • AppsFlyer SDK 4.10.4+
  • p12 certificate. p8 certificates aren't supported. 

Integration procedures

Complete the following sections to set up, integrate, and test iOS uninstall measurement.

Get ID in Apple and set uninstall measurement in AppsFlyer

  1. To find your app id:
    1. In the Apple Developer Members Center, click Identifiers under iOS Apps and locate your app. 

      iOS_Apps_1.png

    2.  If you have not registered an App ID yet, click + and complete the form.
    3. Select Push Notifications.

      iOS_U_T_2.png

    4.  When you expand the application, there are two settings for push notifications with yellow or green status icons:
    5. Click Settings.
       Note The Settings button may be titled Edit if push notifications have been previously configured. If the Settings/Edit button is not available, you may not be the team agent or an admin. The person who originally created the developer account is your team agent and they carry out the remainder of the steps in this section.
  2. To generate your certificate:

    1. Select Apple Push Notification service SSL (Sandbox & Production) in Production certificate option. If you are using VoIP for push notifications, select VoIP Services Certificate.

    2. Click Create Certificate from the Production SSL Certificate option. 

    3. After clicking Create Certificate, note the Add iOS Certificate Assistant. Follow the instructions in the assistant and then click Continue.

    4. Using the Certificate Signing request that was just created, generate the APNS Push SSL certificate.

    5. Once the Download button appears, you are ready to download. You may need to reload the page for this to update. Download the newly created certificate:

    6. Open the certificate. Opening the certificate will open Keychain Access. In the Keychain Access, your certificate is shown under My Certificates. If not, check Certificates to see if it’s located there.

      Note

      Only account admins can upload or change the p12 certificate.

      iOS_U_T_6.png

  3. To renew your certificate
    If you are renewing either your Development or Production Push SSL Certificate, follow the steps listed previously. There is no need to revoke the previous certificate to make this change. Two production certificates can be in use at the same time, allowing you to continue using the old certificate while uploading the new one. Note! don't use development certificates in a production environment. 
  4. To export the P12 File:
    The final step before heading back over to the AppsFlyer dashboard is to save your signing certificate as a .p12 file.
    1. Select the certificate that was just added to Keychain Access

    2. Go to File > Export Items.

    3. Select My Certificates under the Category menu on the lower left-hand side.

      If My Certificates is not highlighted, you cannot export the certificate as a .p12 file.

      iOS_U_T_7.png

      When saving the file, use the Personal Information Exchange (.p12) format.

      Make sure it states Apple Push Services and appears as follows:

      Apple_Push_Services__1_.png

  5. To configure uninstall measurement in AppsFlyer

    1. In AppsFlyer, go to Configuration > App Settings.

    2. Scroll down to the Uninstall section.

    3. Turn on uninstall measurement.

      Uninstall_iOS_p2.png

    4. Click on the upload icon, select the P12 file to upload.

    5. (optional) If the P12 certificate is password protected, fill in the password in the P12 certificate Password

    6. Click Validate to send the certificate to AppsFlyer to check if it is valid.

    7. Click Save Settings.

Integrate with the SDK

Push notifications must be registered at the app's code level to enable uninstall data collection.

Add the following code to your AppDelegate:
SwiftObjective-C

	//add UserNotifications.framework
	import UserNotifications
	func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    //...
    // iOS 10 support
    if #available(iOS 10, *) {
      UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .alert, .sound]){ (granted, error) in }
      application.registerForRemoteNotifications()
    }
    // iOS 9 and iOS 8 support
    else if #available(iOS 8, *), #available(iOS 9, *) {
      UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil))
      UIApplication.shared.registerForRemoteNotifications()
    }

    // iOS 7 support
    else {
      application.registerForRemoteNotifications(matching: [.badge, .sound, .alert])
    }
    
    return true
  }

 // Called when the application sucessfuly registers for push notifications
  func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    AppsFlyerLib.shared().registerUninstall(deviceToken)
  }

The code snippets above request permissions from the user to send push notifications. However, if you are only using push notifications in background mode to measure uninstalls, there is no need to ask for user approval. This is because these push notifications are silent push notifications that do not require you to ask permission from users.

User permission for push notifications in background mode 

If you are only using silent push notifications, make sure to enable Remote Notifications in Background Modes in your app's Capabilities:

  1. In XCode, select your project
  2. Select your target
  3. Switch to Capabilities tab
  4. Toggle Background Modes on
  5. Check Remote notifications

    remote_notifications_xcode.png

Push notifications

Make sure you add Push Notification in your XCode capabilities tab. Without it, the deviceToken is not collected.

capabilities_ios_uninstall.png

Testing iOS uninstalls

To test iOS uninstall measurement:
  1. Install the app.
  2. Uninstall the app.  Note! You can uninstall the app immediately after installing it. 

When testing uninstalls from XCode or TestFlight it is important to let our SDK know that the token is generated from a Sandbox environment. Use the following APIs:

SwiftObjective-C
AppsFlyerLib.shared().setUseUninstallSandbox = true

Note! Uninstalls do not immediately appear in the AppsFlyer dashboard:

    • It takes 9 days on average for uninstalls to appear in reports
    • It can take more than a month for uninstalls originating from sandbox environments to appear in reports

In addition, the date of the uninstall is the date on which the uninstall is reported. See the next section to learn more.

Viewing uninstall data in the AppsFlyer dashboard

Uninstall measurement is displayed on the main dashboard in the Aggregated Performance table.

Due to a recent change in Apple Push Notification service, the time it takes uninstalls to appear on the dashboard is a minimum of 9 days. AppsFlyer updates and aggregates metrics for uninstalls every 24 hours

 Example

  • Day 1: a user installs your app
  • Day 4: a user uninstalls your app
  • Day 12: Apple Push Notification Service reports app removal 8 days after the uninstall
  • Day 13: Uninstall data appear on AppsFlyer dashboard and raw data

Uninstall_measurement_a.png

For more details, refer to the iOS Measure App Uninstalls section of the SDK Integration Guide.

Was this article helpful?