# iOS Install Attribution

WarpLink uses three tiers of attribution matching to connect app installs to the links that drove them.

## Match Cascade

When the app opens, the SDK collects device signals and sends them to the WarpLink API. The server compares them against stored click signals.

| Tier | Method | Signal | Confidence |
|------|--------|--------|------------|
| 1 | Invitation token | Referral invitation, pasted by the person | 1.0 |
| 2 | Repeat check | IDFV | The stored install's own score |
| 3 | Probabilistic | Enriched probabilistic match | Up to 0.85 |

The App Store passes nothing through an install, so a first install on iOS uses the scored match path and returns `matchGuaranteed: false`, unless the person arrives through a [referral invitation](https://warplink.app/docs/guides/referrals) and pastes it. An invitation token match is exact and returns `matchGuaranteed: true`.

### Repeat Checks (IDFV)

Used when the same install asks again, for example after the cached answer was lost or after an update from an older SDK. The IDFV returns the install the device already has, with that install's own match type and confidence, so it never turns a probabilistic match into a guaranteed one. A reinstall is deliberately not answered from this tier. The SDK reports it as a reinstall, and the server records it as a new install through the probabilistic tier, so it is counted when that tier matches a click.

- Signal: `UIDevice.current.identifierForVendor` (IDFV)
- Match type and confidence: those of the install it returns
- Does **not** require ATT permission

IDFV is a UUID shared by every app from the same vendor on one device. Apple resets it when the last app from that vendor is deleted, so for a single-app vendor a reinstall gets a new IDFV. When another app from your vendor stays installed, the IDFV survives the delete, which is why the server never uses it to answer a reinstall the SDK reports as one.

### Probabilistic Matching (Enriched Match Key)

Used for **first-install attribution**, and for a reinstall, which the IDFV tier deliberately leaves to this one. A match here records a new install either way, so a reinstall is counted like a first install.

- Signals: IP address (derived server-side) + normalized primary language + timezone
- Match type: `.probabilistic`
- Confidence: varies by match key variant and elapsed time

#### Match Key Variants

| Variant | Timezone component | Sent by |
|---------|--------------------|---------|
| `enriched_tz` | IANA zone name, for example `America/Toronto` | SDKs that collect a zone name |
| `enriched` | Minute offset | Older SDKs, and devices that cannot resolve a zone |
| `basic` | None | Fallback when neither matches |

The zone name carries far more entropy than the offset (roughly 340 zones against 38 offsets) and does not shift at a daylight-saving boundary. It therefore earns a higher confidence ceiling.

#### Confidence by Elapsed Time

| Time Since Click | `enriched_tz` | `enriched` | `basic` |
|------------------|---------------|------------|---------|
| < 1 hour | 0.85 | 0.80 | 0.70 |
| < 3 hours | 0.65 | 0.60 | 0.50 |
| < 6 hours | 0.50 | 0.45 | 0.35 |
| < 24 hours | 0.30 | 0.25 | 0.20 |

Past 24 hours there is no match at all. The 24 hour band only applies to links whose match window is set past the 6 hour default.

Two further signals adjust the score:

- **Bucket ambiguity.** More than one claimable click shared the match key: x0.6
- **IP sharing.** Carrier-grade NAT or a private address: x0.6. A household IPv4 address: x0.9. IPv6: x1.0

## Reinstalls

A reinstall counts as an install. If the user deletes and reinstalls your app, the SDK runs attribution again and the result lands in your install numbers like any other install.

The attribution request carries `is_reinstall: true` in that case. The SDK reads it from a Keychain marker that outlives an app delete, while the marker that stops a duplicate check inside one install lives in a backup-excluded file and does not. The flag labels the install and never blocks the request. See [App Reinstall](https://warplink.app/docs/sdks/ios/deferred#app-reinstall).

## Referral Invitations

SDK 1.2.0 adds the referral handoff. A friend taps a referral link, the install carries no data, and your first screen offers a paste button that hands the invitation to the SDK. `WarpLinkPasteButton` (SwiftUI) and `WarpLinkUIPasteButton` (UIKit) use the system paste control, so the person pastes with one tap and no prompt. The paste button reads the pasteboard only when the person taps it. Automatic mode reads once on first open, and on call mode reads when your app calls `readTether`. The paste button needs iOS 16; on iOS 15 use `redeemInvitation(text:completion:)` with a text field.

```swift
if #available(iOS 16.0, *) {
    WarpLinkPasteButton { result in
        switch result {
        case .success(let link):
            if link != nil { showInvitationApplied() } // nil: nothing was confirmed
        case .failure(let error):
            showMessage(error.localizedDescription)    // says how to open the link again
        }
    }
} else {
    // iOS 15 has no system paste button. The person pastes into a field.
    // Declare @State private var invitationText = "" in your view.
    VStack {
        TextField("Paste your invitation", text: $invitationText)
        Button("Apply") {
            WarpLink.redeemInvitation(text: invitationText) { result in
                switch result {
                case .success(let link):
                    if link != nil { showInvitationApplied() } // nil: nothing was confirmed
                case .failure(let error):
                    showMessage(error.localizedDescription)    // says how to open the link again
                }
            }
        }
    }
}
```

To redeem text you collected yourself, call `WarpLink.redeemInvitation(text:completion:)`. Text that is not a WarpLink invitation sends nothing and returns `nil`. A match is cached as `attributionResult`, and the paste step never blocks onboarding: skip it and the app stays fully usable. When the network fails, the SDK keeps the invitation on the device and tries again on a later launch, then delivers a match to `onLink`.

After the friend signs up, credit the referral with your own id for them:

```swift
WarpLink.claimReferral(installerId: user.warplinkId) { result in
    if case .success(let claim) = result, claim.status == .claimed {
        // Recorded. Your webhook grants the reward.
    }
}
```

`claimReferral` is safe to repeat, and `.none` is an ordinary answer, not an error. The full path, from link to webhook, is in the [referrals guide](https://warplink.app/docs/guides/referrals).

For a step-by-step setup, follow the [iOS referral quickstart](https://warplink.app/docs/guides/referrals/ios).

## Match Evidence

Every result carries the evidence behind the match, so you can decide how much weight it deserves:

| Property | Meaning |
|----------|---------|
| `attributionId` | A stable id for this attribution. Send it to your backend to claim from there |
| `matchMethod` | `installToken`, `androidReferrer`, `referrer`, `deviceId`, `linkOpen` or `probabilistic`. `androidReferrer` is an invitation token from the Play install referrer. `referrer` is a plain link ID from it, with `evidenceClass` `legacyLink` |
| `evidenceClass` | `exact`, `estimated` (an estimated match from device signals) or `legacyLink` (the link id alone) |
| `replayState` | `original` for the first answer, `replayed` for a repeat of it |
| `capturedParams` | The allowed parameters captured when the link was tapped |
| `tappedAt` | When the link was tapped |

A value this SDK does not know reads as `nil`, and `nil` is never treated as exact.

## Interpreting Results

The `WarpLinkDeepLink` includes `matchType`, `matchConfidence`, and `matchGuaranteed`:

```swift
WarpLink.checkDeferredDeepLink { result in
    if case .success(let deepLink) = result, let deepLink = deepLink {
        print("Link ID:", deepLink.linkId)
        print("Match type:", deepLink.matchType?.rawValue ?? "none")
        print("Confidence:", deepLink.matchConfidence ?? 0)
        print("Guaranteed:", deepLink.matchGuaranteed)
        print("Is deferred:", deepLink.isDeferred)
    }
}
```

## Recommended Thresholds

```swift
WarpLink.checkDeferredDeepLink { result in
    guard case .success(let deepLink) = result, let deepLink = deepLink else {
        showOnboarding() // Organic install
        return
    }

    let confidence = deepLink.matchConfidence ?? 0

    switch confidence {
    case 0.5...:
        navigateTo(deepLink.destination)
    case 0.3..<0.5:
        showSuggestion(deepLink.destination)
    default:
        showOnboarding()
    }
}
```

| Confidence | Recommended Action |
|------------|-------------------|
| 1.0 (deterministic) | Route directly to content |
| > 0.5 (probabilistic) | Route to content: high confidence |
| 0.3–0.5 | Show content with confirmation |
| < 0.3 | Show generic onboarding |

These bands are recommended defaults. Adjust them to fit how sensitive your content is.

### Using `matchGuaranteed`

`matchGuaranteed` is `true` only for an exact match: a tapped link the SDK resolved directly, a referral invitation token, or a Play Install Referrer match on Android. Use it, like `matchConfidence`, to pick the destination the attribution result routes to. Use a probabilistic match to pick a destination with a safe fallback. Keep sign-in on your own authentication.

```swift
if deepLink.matchGuaranteed {
    navigateToSignIn(for: deepLink)
} else {
    navigateTo(deepLink.destination) // public content only
}
```

## App Tracking Transparency

The WarpLink SDK:

- Does **not** use IDFA (Advertising Identifier)
- Does **not** prompt for ATT permission
- Uses only IDFV, which is [exempt from ATT](https://developer.apple.com/documentation/apptrackingtransparency)
- Does **not** interfere with your app's own ATT strategy

## Privacy

### Signals Collected

| Signal | Purpose | Source |
|--------|---------|--------|
| Preferred language | Match key component (server normalizes to the primary subtag) | `Locale.preferredLanguages.first` |
| Timezone name | Match key component, sent as `timezone` by SDKs that collect a zone name | `TimeZone.current.identifier` |
| Timezone offset | Match key component, the fallback for older SDKs | `TimeZone.current.secondsFromGMT()` |
| IDFV | Recognizing the same install asking again | `UIDevice.current.identifierForVendor` |

The IP address is the third match key component. The SDK never sends it: the server derives it from the request. User-Agent and screen dimensions are **not** collected.

### Not Collected

- IDFA (Advertising Identifier)
- Location data
- Contacts or personal data
- App usage data
- Cross-app identifiers

All signals are sent over HTTPS and used solely for attribution matching. No cross-app tracking is performed.

The probabilistic match restores the link a user tapped on the first open after install, for your own app's deferred deep links and install attribution. It does not track users across other companies' apps or websites, and it uses no advertising ID. The server keys the pending deep link by a one-way hash of device signals (HMAC-SHA256 of the IP address, primary language, and time zone). Each tap can be matched only within the app's match window, and pending entries expire automatically. A matched install keeps that hash for your plan's data retention period. The raw IP address is not stored. The time zone is used by the enriched variant only; the basic variant uses the IP address and primary language.

### Privacy Manifest

The SDK ships `PrivacyInfo.xcprivacy`, declaring IDFV collection (App Functionality purpose, not linked to identity, not used for tracking) and its `UserDefaults`/system-boot-time API usage. Xcode aggregates it into your app's privacy report automatically. Reflect device ID collection in your own App Store Connect privacy questionnaire.

## Related

- [Getting more installs matched](https://warplink.app/docs/concepts/attribution#why-an-install-did-not-match)
