iOS SDK

Last updated on Sep 08, 2026

Current SDK release: 0.2.16 (September 2026).

LinkMe iOS SDK

Deep linking, deferred deep linking, and attribution for iOS apps.

CocoaPods License

Quick start

1. Prerequisites

  • A LinkMe account with at least one app configured
  • iOS bundle ID and Apple Team ID added in the LinkMe portal
  • API keys (appId and appKey) from App Settings > API Keys

2. Install

Swift Package Manager (recommended; iOS 14+; macOS 10.15+):

  1. In Xcode: File > Add Packages...
  2. Enter https://github.com/r-dev-limited/li-nk.me-ios-sdk
  3. Select v0.2.16 or a later version tag and add LinkMeKit to your app target. The package manifest is at the repository root.

CocoaPods (legacy):

The v0.2.16 source release is available directly from Git while its CocoaPods trunk spec is being published:

pod 'LinkMeKit', :git => 'https://github.com/r-dev-limited/li-nk.me-ios-sdk.git', :tag => 'v0.2.16'

The current CocoaPods registry spec is pending publication; use SwiftPM or the Git tag above for the current fixes.

3. Configure Universal Links

  1. In Xcode, enable Signing & Capabilities > Associated Domains and add:
applinks:links.yourco.com
  1. Add a custom URL scheme in Info.plist:
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>yourapp</string>
    </array>
  </dict>
</array>

LinkMe hosts the AASA file automatically once your domain is connected.

4. Initialize the SDK

import SwiftUI
import LinkMeKit

@main
struct MyApp: App {
  init() {
    LinkMe.shared.configure(config: .init(
      baseUrl: URL(string: "https://li-nk.me")!,
      appId: "your_app_id",
      appKey: "your_app_key",
      sendDeviceInfo: true,
      includeVendorId: true,
      includeAdvertisingId: false,
      debug: true
    ))
  }

  var body: some Scene {
    WindowGroup {
      ContentView()
    }
  }
}

5. Handle links

struct ContentView: View {
  @State private var message = "Waiting for link…"
  @State private var unsubscribe: (() -> Void)?

  private func display(_ payload: LinkPayload?) {
    guard let payload else { return }
    DispatchQueue.main.async { message = "Opened: \(payload.path ?? "/")" }
  }

  var body: some View {
    Text(message)
      .onOpenURL { LinkMe.shared.handle(url: $0) }
      .onContinueUserActivity(NSUserActivityTypeBrowsingWeb) {
        LinkMe.shared.handle(userActivity: $0)
      }
      .onAppear {
        unsubscribe?()
        unsubscribe = LinkMe.shared.addListener { display($0) }
        LinkMe.shared.getInitialLink { initial in
          if initial != nil { display(initial) }
          else { LinkMe.shared.claimDeferredIfAvailable { display($0) } }
        }
      }
      .onDisappear { unsubscribe?(); unsubscribe = nil }
  }
}

Deferred deep linking

The SDK supports two strategies for first-install attribution:

  1. Pasteboard (deterministic) — reads a cid token written by the LinkMe Edge interstitial before the App Store redirect. Enable Pasteboard for Deferred Links in App Settings.
  2. Fingerprint (probabilistic fallback) — calls /api/deferred/claim when pasteboard is unavailable.

Both are handled automatically by claimDeferredIfAvailable().

API reference

Method Description
configure(config:) Initialize the singleton
handle(userActivity:) Forward NSUserActivity for Universal Links
handle(url:) Forward custom scheme URLs
getInitialLink(completion:) Get the payload that opened the app
addListener(_:) Subscribe to link events (returns unsubscribe closure)
claimDeferredIfAvailable(completion:) Claim deferred deep link on first install
track(event:properties:) Send analytics events
setUserId(_:) Associate a user ID; pass nil to clear it
setAdvertisingConsent(_:) Toggle advertising identifier usage
setReady() Signal readiness to process queued URLs

Example app

The ExampleApp/ directory contains a runnable SwiftUI sample. Update ExampleApp/Configuration/linkme.env with your keys and run on a device or simulator.

License

Apache-2.0

Call LinkMe.shared.setUserId(nil) on logout. SDK callbacks may arrive off the main thread; dispatch UI updates to the main queue, as above.