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

# Unity SDK

> Install the Dashlink Unity plugin, forward live links, and recover the original content after a store install.

The Unity plugin calls the [Android](https://docs.dashlink.ai/guides/app-dynamic-links/android.md) and [iOS](https://docs.dashlink.ai/guides/app-dynamic-links/ios.md) SDKs on Android and iOS player builds. Editor, Windows, macOS, and console builds return no link. Play Install Referrer and Universal Links do not exist there.

The plugin covers Dashlink live-link forwarding and deferred first-open recovery on Android and iOS player builds.

## When you need the SDK

| You have | Use |
| - | - |
| App installed, Dynamic Link host declared, OS verified | Forward the OS URL into `HandleUniversalLink`. |
| First open after a store install from a Dynamic Link | Call `GetDynamicLink` at startup on a device build. |
| Editor or desktop | `IsMobile()` is false. Do not expect a link. |

Android `GetDynamicLink` reads the current activity intent and, on first open, Play Install Referrer. iOS `GetDynamicLink` is only the pasteboard check. A live Universal Link on iOS must go through `HandleUniversalLink`.

## Install

Add the Dashlink Unity package (`ai.dashlink.unity`, Unity 2021.3+) to your project. Until it is published to a registry, install it locally: open **Window → Package Manager → + → Add package from disk…** and select the package's `package.json`, or copy the `dashlink-unity` folder into your project's `Packages/` directory. The Android player also needs `ai.dashlink:dashlink-android:1.0.0` on the Gradle classpath. The iOS player needs the Dashlink pod or Swift package (`Dashlink ~> 1.0.0`) so `DashlinkUnityBridge.mm` can import it.

## Dynamic Link API key

```csharp theme={null}
DashlinkSdk.Configure("dlk_sdk_…");
DashlinkSdk.SetDynamicLinkHosts(new[] { "yourbrand.dshl.in" });
```

Create the key in Settings → API Keys → Type **Dynamic Link**. REST keys (`dlk_live_`) are rejected. `SetDynamicLinkHosts` is required. An empty list lets any https URL with a back-half through.

## Association

Declare the Dynamic Link host in the Android manifest (`autoVerify`) and in the iOS Associated Domains entitlement. The plugin cannot invent OS intercept. See [App association](https://docs.dashlink.ai/guides/app-dynamic-links/app-association.md).

## Live taps and deferred first open

`Samples/DashlinkSample.cs` is the receiver. `OnOpenUrl` forwards a live URL. `GetDynamicLink` runs at startup.

```csharp theme={null}
DashlinkSdk.GetDynamicLink(gameObject.name);
DashlinkSdk.HandleUniversalLink(url, gameObject.name);
```

Results arrive on `OnDynamicLink` as JSON with `appUrl`, `destinationUrl`, `fallbackUrl`, `clickId`, `isDeferred`, `matchType`, `outcome`, UTM fields, and `shortUrl`. Failures arrive on `OnDynamicLinkError`.

An installed tap records `app_open`. A recovered store install records `deferred_open` joined to that `click_id`. A miss is consumed once.

## Tracking

The store redirect is the click. The plugin does not add a second click. Campaign totals should unique-count by `click_id`.

## Test on a device

**1. Uninstall the app**

A previous install will not re-run deferred recovery.

**2. Tap a Dynamic Link**

The device should reach the store.

**3. Install an Android or iOS player build**

Editor Play Mode does not resolve links.

**4. Open the app**

First open must land on `appUrl`, and analytics must show `deferred_open` for the same `click_id`.

## Source

The plugin and a runnable sample live in the [`dashlink-unity`](https://github.com/Dashlink-ai/dashlink-unity) repo; `Samples/DashlinkSample.cs` wires `Configure`, `SetDynamicLinkHosts`, and the live-link and deferred paths.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.