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

iOS 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 (as a Universal Link).
  • Deferred deep link: the game is not installed. The player installs it from the App Store, and the link data is delivered on the first launch.
Availability

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

Native iOS and Unity.

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

Most games only need steps 2 and 4

The SDK already passes every incoming link to AppsFlyer from the app delegate callbacks that the Installation guide requires for social login. If your game already forwards them, step 3 needs no code: add the Associated Domains entry (step 2) and set the delegate (step 4).

Your operator creates the OneLink template in the AppsFlyer dashboard and gives you its domain (for example yourgame.onelink.me). For Universal Links, the template needs the game's Apple Team ID and bundle ID.

2. Associated Domains​

In Xcode, open your app target → Signing & Capabilities → + Capability → Associated Domains, and add:

applinks:yourgame.onelink.me

Replace the domain with your template's domain. This is the same capability TikTok Login uses (see Install: Associated Domains); keep any entries you already have. Deferred deep links do not depend on this step; it is only needed for opening an installed game.

3. Forward app delegate callbacks​

Links reach the SDK through AlogameManager.handleContinueUserActivity(_:) (Universal Links) and AlogameManager.handleOpenURL(_:options:) (URL schemes). Both are already required by the Installation guide; if they are wired, there is nothing to add.

If your app uses a SceneDelegate, iOS delivers links to the scene instead of the AppDelegate, so forward them from there:

SceneDelegate.swift
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
_ = AlogameManager.handleContinueUserActivity(userActivity)
}

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
for context in URLContexts {
_ = AlogameManager.handleOpenURL(context.url, options: [:])
}
}

// Cold launch from a link: the activity arrives in the connection options.
func scene(_ scene: UIScene, willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
connectionOptions.userActivities.forEach { _ = AlogameManager.handleContinueUserActivity($0) }
connectionOptions.urlContexts.forEach { _ = AlogameManager.handleOpenURL($0.url, options: [:]) }
}

In a SwiftUI app, pass the URL from .onOpenURL { url in OEGAnalytics.shared.processDeeplink(url) }.

Set an object that conforms to OEGAttributionDelegate on OEGAnalytics.shared.attributionDelegate, as early as possible (for example in application(_:didFinishLaunchingWithOptions:)).

The delegate is a weak reference

attributionDelegate is weak, like other iOS delegates. Assign an object your game keeps alive for the whole session, such as the AppDelegate itself. A temporary object is released immediately, and links are silently never delivered.

Swift
import OegSdkV2

final class AppDelegate: UIResponder, UIApplicationDelegate, OEGAttributionDelegate {

func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// ... SDK init ...
OEGAnalytics.shared.attributionDelegate = self
return true
}

func oegDidResolveDeepLink(_ data: [String: Any]) {
guard let target = data["deep_link_value"] as? String else { return }
let isDeferred = data["is_deferred"] as? Bool ?? false
// Route the player, e.g. target = "shop", "event_halloween", "invite"
}
}
Objective-C
#import <OegSdkV2/OegSdkV2-Swift.h>

@interface AppDelegate () <OEGAttributionDelegate>
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// ... SDK init ...
OEGAnalytics.shared.attributionDelegate = self;
return YES;
}

- (void)oegDidResolveDeepLink:(NSDictionary<NSString *, id> *)data {
NSString *target = data[@"deep_link_value"];
if (![target isKindOfClass:[NSString class]]) return;
// Route the player using target
}

@end
  • The callback always runs on the main thread.
  • A deferred deep link usually resolves right at startup, often before your delegate is set. The SDK holds the most recent link and delivers it once to the next delegate you set, so setting it a bit late does not lose it.
  • Setting another delegate replaces the previous one. Set it to nil 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 an NSNull value.

ATT is not required​

OneLink, and AppsFlyer attribution in general, works whether the player allows or denies the App Tracking Transparency prompt. See App Tracking Transparency.

Testing​

  1. Ask your operator for a OneLink with a deep_link_value you handle.
  2. Direct: with the game installed, open the link from Notes or Messages (Universal Links do not open when the link is typed into Safari's address bar). The game should open and your delegate should fire with is_deferred = false.
  3. Deferred: delete the game, open the link, install the build, and launch it. Your delegate should fire once with is_deferred = true.

If nothing arrives, check that the game's attribution provider is AppsFlyer, that the Associated Domains entry matches the template's domain, and that the template's Team ID and bundle ID match the build you installed.