Use the Adjust Android SDK to measure uninstalls and reinstalls. Adjust uses push tokens to send silent push notifications to your users’ device, and checks if your app is currently installed.
Use the following instructions to add this functionality to your app.
Before you begin
Here’s what you need to know before getting started.
Requirements
- Android SDK v4.12.0 and later
- Add Firebase to your Android project
- Admin, Editor, or Custom Editor permissions
Connect Google FCM to Adjust
Configuring silent push notifications through Google’s Firebase Cloud Messaging (FCM) API allows you to measure uninstalls and reinstalls. Adjust requires an FCM HTTP v1 API private key to connect to Google FCM.
Google Cloud console
1. Create a custom role for Adjust Uninstall and Reinstall Measurement
- Access your Google Cloud Console.
- Select the Google Cloud project associated with your Firebase project.
- Search for IAM & Admin.
- From the side menu, select Roles.
- Select + Create Role.
- Enter the following details:
- Title: Adjust Uninstall
- ID: adjust_uninstall
- Role launch stage: General Availability
- Select + Add Permissions.
- In the Enter property name or value field, enter
cloudmessaging.messages.create
and select it from the search results. - Check the cloudmessaging.messages.create option and select Add.
- Select Create.
2. Create a service account
- From the side menu, select Service Accounts.
- Select + Create Service Account.
- In the Service account name field, enter
Adjust Uninstall Service Account
. - Select Create and Continue.
- Select the Select a role dropdown. Enter
Adjust Uninstall
and select it from the search results. - Select Continue.
- Select Done.
3. Generate and download the private key
- Select the newly created service account. The format looks like this:
adjust-uninstall-service-account@test3-55065.iam.gserviceaccount.com
. - Select the Keys tab.
- Select Add Key > Create new key.
- Select JSON and then Create. The private key is downloaded as a JSON file to your computer.
In the Adjust dashboard
Now that you have the private key details required to connect Adjust to Google FCM, you need to enable Uninstall and reinstall measurement in your app configuration in AppView:
- Select the Platforms tab.
- Select Edit.
- Under Advanced settings, find the Record uninstall and reinstall data option.
- Select Add connection. A modal will open prompting you to add a new connection between Adjust and Google FCM.
- Fill in the required information including your recently generated FCM private key. The Partner and Services fields are automatically filled in.
- Select Connect.
- Review your app’s settings and select Save.
Integrate with the Adjust SDK
Follow these instructions to integrate FCM with the Adjust SDK:
-
Ensure that you have the required dependency for Firebase Messaging in your
build.gradle
file: -
Set up a Firebase Cloud Messaging client app on Android following Google’s documentation, if you haven’t already done so.
-
Pass the push token for the device to the Adjust SDK.
- If you are sending your own push notifications to the app, ensure that you override the
onMessageReceived
method in theFirebaseMessagingService
class with logic that handles all types of push notifications, including Adjust’s silent push notifications for Uninstall and Reinstall Measurement.
- If you are sending your own push notifications to the app, ensure that you override the
Example
The following code snippet shows how you can extend the FirebaseMessagingService
class to pass the push token to the Adjust SDK, and to update your push notification handling logic. If you aren’t sending your own push notifications, you can skip the override of the onMessageReceived
method.
- Initialize the Firebase instance in your application before initializing the Adjust SDK.
Example
Here is an example of an application class in an Android project. You can see that it initializes the Firebase instance as soon as the app starts.
Test the integration
Adjust checks for Android app uninstalls from devices that had their last activity in the Adjust production environment.
To test Uninstall and Reinstall measurement, you can use either a debug build or a release build. The main requirement is that you must set the Adjust SDK environment to production when performing test installs.
To test uninstall measurement:
- In the Adjust SDK, set the environment to
AdjustConfig.ENVIRONMENT_PRODUCTION
before initializing the Adjust SDK. - Install the app on your physical test device or emulator.
- Open the app.
- Open Adjust’s Testing Console.
- Enter your device ID and select View device data.
- Under the App information section:
- The Install state should show Installed.
- There should be a value for Push token.
- Uninstall the app.
- After 24 hours, check the Testing Console again, as Adjust checks for uninstalls once a day. Under the App information section, the Install state should now show Uninstalled.
The state change from Installed to Uninstalled ensures that the Uninstall and Reinstall measurement feature works correctly. However, if you would also like to test reinstall measurement, follow the next steps:
- Reinstall the debug build or release build on your physical test device or emulator.
- Open the app.
- After 24 hours, check the Testing Console again as Adjust checks for reinstalls once a day. Under the App information section, the Install state should show Reinstalled.
Troubleshooting
The following are the most common issues when testing uninstall and reinstall measurement:
- The Adjust SDK environment is set to
AdjustConfig.ENVIRONMENT_SANDBOX
when the test install occurs. Uninstall and Reinstall measurement won’t work with this setting. Make sure to change the setting in the Adjust SDK toAdjustConfig.ENVIRONMENT_PRODUCTION
. - The push token is missing. If the push token doesn’t appear in the Testing Console, there might be something wrong with your Firebase implementation or with the code that integrates the Firebase SDK and the Adjust SDK. Review these elements of your implementation.
- There is an issue with the FCM HTTP v1 API private key. For example, the private key that you generated may belong to the wrong project, or you may have entered the details incorrectly into Adjust Suite. Review these points, and if necessary, reach out to your Technical Account Manager or support@adjust.com with your device’s push token. They can pull logs to check the response from Google’s API.
After resolving any issue, follow the these steps to test the implementation again:
- Uninstall the app.
- In the Testing Console, enter your device ID, and select View device data > Forget Device.
- Repeat the steps under the Test the integration section.