# iOS Deep Linking

LinkSense — a dynamic link management platform — supports iOS Universal Links so a tap on a LinkSense URL opens directly in your iOS app instead of Safari. iOS uses the Apple App Site Association (AASA) file to verify the link belongs to your app. LinkSense hosts the AASA automatically; you only need to register your app and configure your Xcode project.

## Prerequisites

- An [Apple Developer account](https://developer.apple.com/account) with active membership.
- Your app's Bundle Identifier (e.g. `com.example.myapp`).
- Your Apple Team ID (10-character alphanumeric like `A1B2C3D4E5`).
- A LinkSense project with a subdomain.

## Register your iOS app

In the LinkSense dashboard, open your project's **Apps** tab and add an iOS app. Provide:

- **App name** — friendly label.
- **Bundle ID** — your app's Bundle Identifier.
- **Team ID** — your Apple Developer Team ID.
- **App Store ID** — found in App Store Connect under App Information; used for fallback redirects when the app isn't installed.

## Apple App Site Association (AASA)

LinkSense generates and hosts the AASA file at:

```
https://<your-subdomain>.linksense.net/.well-known/apple-app-site-association
```

The file has the structure:

```json
{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appIDs": ["TEAM_ID.com.example.myapp"],
        "paths": ["*"]
      }
    ]
  }
}
```

The file updates automatically whenever you add or remove iOS apps from the project. No manual hosting.

## Configure your Xcode project

1. Open your project in Xcode.
2. Select your app target → **Signing & Capabilities**.
3. Click **+ Capability** → add **Associated Domains**.
4. Add an entry with your LinkSense subdomain.

Your entitlements file should include:

```xml
<key>com.apple.developer.associated-domains</key>
<array>
  <string>applinks:your-subdomain.linksense.net</string>
</array>
```

## Test Universal Links

1. Install your app on a physical device — Universal Links don't work in the simulator.
2. Open Notes or Messages and paste your dynamic link URL.
3. Tap the link — it should open directly in your app.
4. If the link opens in Safari instead, long-press it and look for an **Open in [App]** option.

Universal Links never trigger if you type the URL into Safari's address bar. They only fire from taps on links in other apps (Notes, Mail, Messages, third-party apps).

## See also

- [Android Deep Linking](https://linksense.net/docs/android-deep-linking.md)
- [Dynamic Links](https://linksense.net/docs/dynamic-links.md)
- Apple's guide: [Supporting Universal Links in Your App](https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app)
