Chuyển tới nội dung chính

Android OneLink (AppsFlyer Deep Links)

When a player taps an AppsFlyer OneLink, the SDK resolves it through AppsFlyer and hands the link's data to your game, so you can open the right screen, apply a promo code, credit a referral, and so on.

It covers both cases:

  • Direct deep link: the game is already installed, and the link opens it.
  • Deferred deep link: the game is not installed. The player installs it from the store, and the link data is delivered on the first launch.
Availability

Requires an SDK release after Android 1.4.21, and AppsFlyer as the game's attribution provider (attribution_provider: "appsflyer", set by your operator). With Adjust, or with no provider, the listener is never called.

Native Android and Unity.

The SDK only delivers the link data. Deciding where it leads inside the game is your game's job.

Your operator creates the OneLink template in the AppsFlyer dashboard and gives you its domain (for example yourgame.onelink.me). For Android App Links, the template needs the game's package name and the SHA-256 fingerprint of the certificate that signs the build players install. For builds distributed through Google Play, that is the Play App Signing certificate, not your upload key.

Test builds you install yourself (an APK from Android Studio or a sideloaded release build) are signed with a different certificate. Add that certificate's SHA-256 to the template as well, or the link will not open the game on test devices. A template accepts more than one fingerprint. To print a keystore's fingerprint:

keytool -list -v -keystore your-release.keystore -alias your-alias

2. Declare the SDK's OneLink entry Activity​

Add this block to your app's AndroidManifest.xml, inside <application>, with your template's domain as the host. Do not change android:name: it refers to an Activity that ships inside the SDK, and Android's manifest merger attaches your intent filter to it.

AndroidManifest.xml
<activity
android:name="vn.oeg.sdk.v2.core.analytics.OneLinkEntryActivity"
android:exported="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="https"
android:host="yourgame.onelink.me" />
</intent-filter>
</activity>

That is the only code change. When a player taps the link, this Activity passes it to AppsFlyer and brings your game forward through its normal launcher, the same as tapping the app icon: a running game resumes where it was, and a cold start goes through your own splash screen. You do not forward onCreate or onNewIntent, and a splash Activity cannot lose the link.

  • Keep android:exported="true". Android requires it on any Activity with an intent filter; the build fails without it.
  • Leave your launcher Activity and its intent filter as they are. Do not add the OneLink filter there as well.
  • Deferred deep links do not depend on this step. It is only needed for opening an installed game.
Handling the link in your own Activity instead

Only if your game already routes App Links through its own Activity. Put the filter on the Activity that stays open, not on a splash Activity that starts the game Activity with new Intent(this, MainActivity.class) and finishes, which drops the link. Then pass the link to the SDK yourself; this is the same call described in Deep Link Reattribution:

Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent?.data?.let { OEGAnalytics.processDeeplink(it, this) }
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
setIntent(intent)
intent.data?.let { OEGAnalytics.processDeeplink(it, this) }
}
Java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Uri data = getIntent() != null ? getIntent().getData() : null;
if (data != null) OEGAnalytics.INSTANCE.processDeeplink(data, this);
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
if (intent.getData() != null) OEGAnalytics.INSTANCE.processDeeplink(intent.getData(), this);
}

onNewIntent is called when the Activity is already running and declared singleTask or singleTop. With the default launch mode, a link creates a new instance instead and arrives in onCreate. A link passed before the SDK has loaded its configuration is held and processed once it has.

Register an AttributionListener once, as early as possible, for example in your main Activity's onCreate:

Kotlin
import vn.oeg.sdk.v2.core.analytics.OEGAnalytics

OEGAnalytics.setAttributionListener(object : OEGAnalytics.AttributionListener {
override fun onDeepLinkResolved(data: Map<String, Any?>) {
val target = data["deep_link_value"] as? String ?: return
val isDeferred = data["is_deferred"] as? Boolean ?: false
// Route the player, e.g. target = "shop", "event_halloween", "invite"
}
})
Java
import vn.oeg.sdk.v2.core.analytics.OEGAnalytics;
import java.util.Map;

OEGAnalytics.INSTANCE.setAttributionListener(new OEGAnalytics.AttributionListener() {
@Override
public void onDeepLinkResolved(Map<String, ?> data) {
Object target = data.get("deep_link_value");
if (target == null) return;
// Route the player using target.toString()
}
});
  • The callback always runs on the main thread.
  • A deferred deep link usually resolves right at startup, often before your listener is registered. The SDK holds the most recent link and delivers it once to the next listener you register, so registering a bit late does not lose it.
  • Registering again replaces the previous listener. Pass null to stop receiving links.

data is AppsFlyer's raw click-event payload. Which keys are present depends on how the OneLink was built, so treat every key as optional:

KeyMeaning
deep_link_valueThe main routing value you set on the link (e.g. shop)
deep_link_sub1 … deep_link_sub10Extra values you set on the link
is_deferredtrue when delivered on the first launch after install
media_source, campaign, campaign_idAttribution info of the link
af_sub1 … af_sub5Legacy custom parameters
match_type, click_http_referrerDiagnostic information from AppsFlyer

Values are usually strings; is_deferred is a boolean. A key can be present with a null value.

Testing​

  1. Ask your operator for a OneLink with a deep_link_value you handle.

  2. App Links verification: install the build and check that Android verified the OneLink domain:

    adb shell pm get-app-links your.package.name

    The OneLink domain should show verified. Anything else (legacy_failure, none) means the template's package name or SHA-256 fingerprint does not match this build. Android then opens the link in the browser, not the game. Verification runs at install time, so reinstall after changing the template.

  3. Direct: with the game installed, open the link from a messaging or notes app (not by typing it in the browser address bar). The game should open and your listener should fire with is_deferred = false.

  4. Deferred: uninstall the game, open the link, install the build, and launch it. Your listener should fire once with is_deferred = true.

If the game opens but nothing arrives, check that the game's attribution provider is AppsFlyer and that the listener is registered. If you handle the link in your own Activity, also check that it reaches processDeeplink.