The Adjust Android SDK enables you to record attribution, events, and more in your Cocos2d-x app. Follow the steps in this guide to set up your app to work with the Adjust SDK.
1. Install the SDK
To start using SDK v5, you need to add it as a dependency in your project. To do this:
Download the SDK archive from GitHub
Copy the C++ files from the
dist
directory and add them to your Cocos2d-x project(Android only): add the paths of the C++ files to the
LOCAL_SRC_FILES
section of yourAndroid.mk
file.If you're using CMake, add the following list of sources and headers to your
CMakeLists.txt
file:(Android only): download the latest
adjust-android.aar
from the GitHub releases page and import it into your Android Studio project.(iOS only): download the latest
AdjustSdk.framework
from the GitHub releases page and link it in your Xcode project.
2. Set up the Signature library
SDK v5 uses the SDK signature library to encrypt information sent from the Adjust SDK to Adjust's servers. You MUST add the signature library to your project to use SDK v5.
Android apps
- Download the latest
adjust-android-signature.aar
from the Adjust Signature library GitHub repository. - Add the
.aar
to your Android Studio project.
iOS apps
- Download the latest
AdjustSigSdk-iOS-Static.a
from the Adjust Signature library GitHub repository. - Link the
.a
in your Xcode project.
3. Configure Android settings
Follow these steps to configure the Adjust SDK for Android devices.
Permissions
The Adjust Android SDK comes with required permissions preconfigured. This includes the com.google.android.gms.permission.AD_ID
permission. If your app needs to be compliant with the Children's Online Privacy Protection Act (COPPA), you MUST remove this permission by adding the following to your AndroidManifest.xml
file:
To learn more about COPPA, read Adjust's COPPA compliance article.
Add Google Play Services
Apps that target the Google Play Store must use the Google Advertising ID (gps_adid
) to identify devices. To do this, add the following dependency to the dependencies
section of your build.gradle
file.
Set up install referrer
The install referrer is an attribution mechanism you can use to attribute an app install to a source. It consists of two parts:
- A set of APIs from these app stores that allow developers to retrieve referral content in their apps.
- A
referrer
parameter that app stores, such as Google Play and Huawei App Gallery, accept in their app page URLs on their store websites. Here is how the referrer parameter is populated:- When a user clicks on an Adjust link, the Adjust server passes a unique identifier called
reftag
. This identifier is assigned to the click and into the referrer parameter. To learn more about reftag, see the Reftag article in the Help Center. - When you run Google Ads campaigns, Google passes a unique identifier called
gclid
into the referrer parameter. You MUST enable Auto-tagging in your Google Ads account.
- When a user clicks on an Adjust link, the Adjust server passes a unique identifier called
Google Play Referrer API
To support the Google Play Referrer API, follow these steps:
Add the Google Maven repository to your
build.gradle
file.Add the Install Referrer library to your
build.gradle
file.
Meta Install Referrer
The Adjust SDK supports the Meta Install Referrer using the Adjust Meta Install Referrer plugin. See the Cocos2d-x Meta Install Referrer plugin for integration details.
4. Configure iOS settings
Follow these steps to configure the Adjust SDK for iOS devices.
Link additional frameworks
Link the following frameworks to your Xcode project to give the Adjust SDK access to device-level information.
Framework | Purpose | Notes |
---|---|---|
AdSupport.framework | Required to enable the Adjust SDK to read the device IDFA. | You MUST NOT add this framework if your app targets the "Kids" category |
AdServices.framework | Required for handling Apple Search Ads | |
StoreKit.framework | Required to access the SKAdNetwork framework and for the Adjust SDK to handle communications with SKAdNetwork. | |
AppTrackingTransparency.framework | Required in iOS 14 and later to enable the Adjust SDK to wrap the ATT consent dialog and access the user's consent response. | You SHOULD NOT add this framework if your app targets the "Kids" category |
Copy additional source files
To complete iOS setup, you MUST copy all Objective-C++ (.h
and .mm
) files from the dist
directory of the unzipped SDK archive to your Xcode project. Ensure that all .mm
files are listed in the Build Phases --> Compile Sources section.
Update your app's privacy manifest
To inform the App Store of the Adjust SDK's privacy requirements, you need to merge your privacy manifest with Adjust's privacy manifests.
- Add the Adjust SDK privacy manifest properties to your app's privacy manifest.
- Add the Signature library privacy manifest properties to your app's privacy manifest.
6. Integrate the Adjust SDK
Once you've updated your project settings, you can integrate the Adjust SDK into your app. To do this:
Find your application delegate file in the Project Navigator and open it.
Include the
Adjust/Adjust2dx.h
class at the top of the file.Instantiate an
AdjustConfig2dx
object with the following arguments:appToken
(std::string
)Your Adjust app token
environment
(std::string
)Pass
AdjustEnvironmentSandbox2dx
to test your app in a sandbox environment.
Optionally adjust your logging level to adjust the verbosity of your logging.
Call the
Adjust2dx::initSdk
method and pass yourAdjustConfig2dx
instance as an argument as soon as possible after the app is launched.
7. Build your app
Well done! You should now be able to build and run your Cocos2d-x app. Enable logging to check for any issues. Check your logs to see the Install tracked
message.
You are ready to start attributing your users with the Adjust SDK.