> ## Documentation Index
> Fetch the complete documentation index at: https://help.airbridge.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Uninstall Tracking Setup - Expo SDK

Airbridge sends silent push notifications to users who have performed any app event at least once in the past 6 months to check if they have deleted the app. These notifications are sent daily between 3:00 PM and 4:00 PM (UTC). Uninstall events can be monitored in the Airbridge reports and raw data export files.

## Submit Credentials

Submit your Apple Developer or Google Cloud Console credentials to Airbridge.

### Get credentials from Apple Developer

Follow the steps below to get the required credentials from the Apple Developer Portal.

<AccordionGroup>
  <Accordion title="APNs Authentication Key (p8) and Key ID">
    To get the APNs authentication key, you need to turn on the app's push notification from the Apple Developer Portal.

    1. Select **\[Identifiers]** in the [Apple Developer Portal](https://developer.apple.com/account/resources).
    2. Find and click on the app you want to track uninstalls. Then, check "Push Notification."
    3. Select **\[Keys]**. Click **+** to generate a new key. Then, download the APNs authentication key (p8). The APNs authentication key can be downloaded only when creating the key for the first time and cannot be downloaded again. If lost, the key must be regenerated. Up to 2 APNs authentication keys can be generated at once.
    4. The Key ID can be found when clicking on the newly generated key in **\[Keys]**.
  </Accordion>

  <Accordion title="Bundle ID">
    Navigate to **\[Certificates, Identifiers & Profiles]>\[Identifiers]** in the [Apple Developer Portal](https://developer.apple.com/account/resources). Click on the app you want to track uninstalls to find the Bundle ID.
  </Accordion>

  <Accordion title="Team ID (App ID Prefix)">
    Navigate to **\[Account]>\[Membership details]** in the [Apple Developer Center ](https://idmsa.apple.com/IDMSWebAuth/signin?appIdKey=891bd3417a7776362562d2197f89480a8547b108fd934911bcbea0110d07f757\&path=%2Faccount%2F\&rv=1#MembershipDetailsCard)to find the Team ID (App ID Prefix).
  </Accordion>
</AccordionGroup>

### Get credentials from Google Cloud Console

Follow the steps below to get the required credentials from the Google Cloud Console.

<AccordionGroup>
  <Accordion title="Enabling the API">
    Follow the steps below to enable the Google Cloud API required for Android app uninstall tracking.

    1. Log in to the Google Cloud Console. Select the project for uninstall tracking from the dropdown list.
    2. Navigate to \[APIs & Services] > \[Library].
    3. Enter 'Firebase' in \[Search for APIs & Services] and press Enter.
    4. Scroll through the search results and click on 'Firebase Cloud Messaging API'.
    5. Click 'Enable'.
  </Accordion>

  <Accordion title="Create a custom role">
    Create a custom role following the steps below.

    1. Sign in to the Google Cloud console. From the drop-down list, select a project to create a custom role.

    2. Navigate to **\[IAM & Admin]>\[Roles]**. Click **+ Create Role**.

    3. Enter the following details:

    * Title: Airbridge Uninstalls
    * ID: abr\_uninstalls
    * Role launch stage: General Availability

    4. Click **+Add Permissions**.

    5. In the **Enter property name or value** field, enter "cloudmessaging.messages.create" and select it from the search results. Check the checkbox and click **Add**.

    6. Click **Create** to finish creating the custom role.
  </Accordion>

  <Accordion title="Create a service account">
    Create a service account by following the steps below.

    1. Navigate to **\[IAM & Admin]>\[Service Accounts]**. Click **+ Create Service Account**.

    2. Enter “ABR Uninstall Service Account” as the service account name. Click **Create and Continue**.

    3. From the **Select a role** drop-down list, search and select "Airbridge Uninstalls." Click **Continue**.

    4. Click **Done** to finish creating the service account.
  </Accordion>

  <Accordion title="Create a private key">
    Create a private key file of the service account.

    1. Navigate to **\[IAM & Admin]>\[Service Accounts]**. From the service account list, click the email of the service account whose name is "ABR Uninstall Service Account."

    2. Select the **Keys** tab. Click **Add Key** and select **Create new key**.

    3. Select **JSON** as the key type and click **Create**. The JSON file containing the key file will be downloaded. Make sure to securely store the JSON file.
  </Accordion>
</AccordionGroup>

### Submit credentials to Airbridge

#### iOS

Follow the steps below to submit the credentials to Airbridge.

1. Navigate to **\[Settings]>\[Uninstall Tracking]** in the Airbridge dashboard.

2. Select the **\[iOS]** tab.

3. Submit the required credentials.

<Frame>
  <img src="https://mintcdn.com/airbridge-help-center/WCTn-oGPmrNYnPbt/asset/image/ios-uninstall-apns-credentials.png?fit=max&auto=format&n=WCTn-oGPmrNYnPbt&q=85&s=695ba723dad795edac91d34562aefb00" alt="01-en-uninstalltracking iOS" width="1400" height="800" data-path="asset/image/ios-uninstall-apns-credentials.png" />
</Frame>

##### Select app environment

After submitting all the required credentials to Airbridge, select the app environment to collect push tokens.

<Frame>
  <img src="https://mintcdn.com/airbridge-help-center/WCTn-oGPmrNYnPbt/asset/image/ios-uninstall-app-environment.png?fit=max&auto=format&n=WCTn-oGPmrNYnPbt&q=85&s=91c77e62cf704fccc3c38b7cbcfbf776" alt="02-en-uninstalltracking iOS" width="1400" height="800" data-path="asset/image/ios-uninstall-app-environment.png" />
</Frame>

Different push tokens are collected depending on the app environment you choose. For example, push tokens collected in the production environment cannot be used in the development environment.

<AccordionGroup>
  <Accordion title="Production">
    * Supported apps: Apps downloaded from the Apple App Store or test apps released via TestFlight, Ad Hoc, or Enterprise
    * Push tokens collected: The actual push tokens used for uninstall tracking
  </Accordion>

  <Accordion title="Development">
    * Supported app: Development apps for testing purposes that are not supported in the production environment
    * Push token collected: Push token used in the development environment

    In the development environment, you can only proceed with silent push testing. To actually track uninstalls, proceed with a production app.
  </Accordion>
</AccordionGroup>

#### Android

Follow the steps below to submit Firebase credentials to Airbridge.

1. Navigate to **\[Settings]>\[Uninstall Tracking]** in the Airbridge dashboard.

2. Select the **\[Android]** tab.

3. Upload the JSON key file by dropping the file or clicking to select the file.

<Frame>
  <img src="https://mintcdn.com/airbridge-help-center/0NLx_yaUdxu9z1c9/asset/image/android-uninstall-tracking-private-key-upload.png?fit=max&auto=format&n=0NLx_yaUdxu9z1c9&q=85&s=0ea7f8725e24823d44a8c371e2a0275e" alt="uninstall-dev-en-05" width="1400" height="800" data-path="asset/image/android-uninstall-tracking-private-key-upload.png" />
</Frame>

### Test silent push notifications

#### iOS

Test silent push notifications to make sure the notifications are successfully sent to the devices. To proceed with the test, click **Test silent push.** The silent push test does not measure or generate uninstall events; therefore, uninstalls cannot be confirmed in the Airbridge dashboard.

Conducting the silent push test is recommended as the Bundle ID, which is one of the required credentials for uninstall tracking, can only be validated through the silent push test.

<Frame>
  <img src="https://mintcdn.com/airbridge-help-center/WCTn-oGPmrNYnPbt/asset/image/ios-silent-push-test-button.png?fit=max&auto=format&n=WCTn-oGPmrNYnPbt&q=85&s=9808d4921c179009d00f9396277fd169" alt="03-en-uninstalltracking iOS" width="1400" height="800" data-path="asset/image/ios-silent-push-test-button.png" />
</Frame>

To conduct a silent push test, you need an APNs push token (device token). The push token you collect varies depending on the app environment. You need to check the push token and the app environment before proceeding with a silent push test. Refer to the [Apple Developer Documents](https://developer.apple.com/documentation/usernotifications/registering_your_app_with_apns) for instructions on how to find the APNs push token.

<Frame>
  <img src="https://mintcdn.com/airbridge-help-center/WCTn-oGPmrNYnPbt/asset/image/ios-silent-push-test-modal.png?fit=max&auto=format&n=WCTn-oGPmrNYnPbt&q=85&s=a73af0f3a441876f2351795597d11ad2" alt="04-en-uninstalltracking iOS" width="1400" height="800" data-path="asset/image/ios-silent-push-test-modal.png" />
</Frame>

Upon sending a silent push to a device from Airbridge, you can check for a success message or an error code. The main error codes that can be received are as follows. For more information about the error codes, refer to the [Apple Developer Documents](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/handling_notification_responses_from_apns#3394541).

<Accordion title="Error codes - Silent push test">
  | Error Code                     | Meaning                                                                                                                                                    |
  | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | **403 (InvalidProviderToken)** | Invalid APNs credentials. Enter the correct Key ID and Team ID, and try again.                                                                             |
  | **400 (TopicDisallowed)**      | Invalid Bundle ID. Enter the correct Bundle ID, and try again.                                                                                             |
  | **400 (BadDeviceToken)**       | Invalid push token. The actual app environment and the app environment configuration may not match.                                                        |
  | **410 (Unregistered)**         | Invalid push token. The actual app environment and the app environment configuration may not match, or the user may have deleted the app several days ago. |
  | **410 (ExpiredToken)**         | Invalid push token. The actual app environment and the app environment configuration may not match, or the user may have deleted the app several days ago. |

  Some error codes that indicate that the app has been deleted could show as a result of the silent push test. Regardless, be reminded that the purpose of the silent push test is to verify whether silent push notifications are being sent successfully using the submitted credentials.

  Test the silent push notification on a device for testing purposes where the app has been installed recently and retained for the last 10 days.
</Accordion>

<Danger>
  **Attention**

  You can't conduct silent push tests on iOS Simulators.
</Danger>

#### Android

Test silent push notifications to make sure the notifications are successfully sent to devices. To proceed with the test, click **Test silent push** and enter the FCM registration token of your test device. For detailed instructions on how to access your FCM registration token, refer to the [Firebase documentation](https://firebase.google.com/docs/cloud-messaging/android/first-message#access_the_registration_token).

<Frame>
  <img src="https://mintcdn.com/airbridge-help-center/0NLx_yaUdxu9z1c9/asset/image/android-uninstall-tracking-silent-push-test.png?fit=max&auto=format&n=0NLx_yaUdxu9z1c9&q=85&s=86696826f39271f359b4aee17ebdd42b" alt="uninstall-dev-en-06" width="1400" height="800" data-path="asset/image/android-uninstall-tracking-silent-push-test.png" />
</Frame>

A success message will be shown when a silent push notification is successfully sent to your test device where the app is installed. A fail message containing the 404 error code will be shown when a silent push notification is successfully sent to a test device where the app is uninstalled.

Find the complete list of error codes below. For details about the error codes, refer to the  [Firebase documentation](https://firebase.google.com/docs/reference/fcm/rest/v1/ErrorCode).

<Accordion title="Error codes - Silent Push Test">
  | Error code                | HTTP Error Code | Description                                                                                                                       |
  | ------------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------- |
  | INVALID\_ARGUMENT         | 400             | Invalid request parameters. Check the package name, data key, etc.                                                                |
  | THIRD\_PARTY\_AUTH\_ERROR | 401             | Invalid or missing APN certificate or web push auth key. Check the validity of your credentials.                                  |
  | SENDER\_ID\_MISMATCH      | 403             | The authorized sender ID and the sender ID of the registered token don't match. Check the sender ID.                              |
  | UNREGISTERED              | 404             | Invalid token, which Airbridge assumes that the app has been uninstalled. Airbridge can successfully collect the Uninstall event. |
  | QUOTA\_EXCEEDED           | 429             | The sending limit was exceeded.                                                                                                   |
  | INTERNAL                  | 500             | An error occurred in the Firebase server. Retry after a moment. If this error persists, contact Firebase for troubleshooting.     |
  | UNAVAILABLE               | 503             | The Firebase server is overloaded. Retry after a moment.                                                                          |
</Accordion>

Testing silent push notifications test does not affect the uninstall event count that is available in Airbridge reports and raw data export files. Note that testing silent push notifications does not result in the actual uninstall event collection.

## Set Up the Airbridge SDK

For uninstall tracking, you must complete the Airbridge SDK setup by following the instructions below.

### Enable push notifications

Airbridge tracks app deletions through silent push notifications. Therefore, you need to set up the app to receive push notifications.

### Send the push token

When the push token is generated, call the `registerPushToken` function to send it to the SDK.

```typescript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
import { Airbridge } from 'airbridge-react-native-sdk'
...
Airbridge.registerPushToken(token)
```

<Danger>
  **Attention**

  On iOS, the APNS push token should be sent. On Android, the Firebase push token should be sent.
</Danger>

### Silence push notifications

The silent push notifications Airbridge sends for uninstall tracking should not be displayed in the user's app. By adding the exception handling code as below, the silent push will not be exposed to the user.

```typescript lines theme={"theme":{"light":"github-dark-dimmed","dark":"github-dark-dimmed"}}
import { Airbridge } from 'airbridge-react-native-sdk'
...
if (Airbridge.isUninstallTrackingNotification(payload)) {
    return
}
```

## Enable Uninstall Tracking

After submitting the credentials to Airbridge and completing the SDK setup, the \[Enable uninstall tracking] toggle will be activated. Switch on the toggle to start tracking uninstall events.

For more details about uninstall tracking, refer to this [article](/en/guides/uninstall-event-tracking).

<Frame>
  <img src="https://mintcdn.com/airbridge-help-center/WCTn-oGPmrNYnPbt/asset/image/ios-uninstall-tracking-toggle.png?fit=max&auto=format&n=WCTn-oGPmrNYnPbt&q=85&s=bf6db2953571002aed76337288896818" alt="05-en-uninstalltracking iOS" width="1400" height="800" data-path="asset/image/ios-uninstall-tracking-toggle.png" />
</Frame>

<link rel="alternate" hrefLang="en" href="https://help.airbridge.io/en/developers/uninstall-tracking-expo-sdk-v4" />

<link rel="alternate" hrefLang="ko" href="https://help.airbridge.io/ko/developers/uninstall-tracking-expo-sdk-v4" />
