Docs

API reference

Every public type, method, property and field in the Lander iOS SDK 0.1.0.

Everything below comes from one module:

import Lander
ExportKind
LanderStatic entry point (an enum with no cases)
LanderLinkA link delivered to the app
LanderShortLinkA link created with createLink
LanderParamValueA link param value: string, number or boolean
LanderConfidenceEnum: how sure Lander is
LanderErrorError thrown by initialize, createLink and claimHandoff
LanderSubscriptionToken returned by onDeepLink

Every public type is Sendable, and the SDK builds in Swift 6 language mode with strict concurrency checking. Every Lander member can be called from any thread or actor, except the @MainActor UIKit helpers noted below.

Lander

public enum Lander

All members are static. You never create an instance.

Lander.initialize

static func initialize(
  apiKey: String,
  baseURL: URL = Lander.defaultBaseURL,
  enableLogging: Bool = false
) throws

Starts the SDK. Call it once, as early as possible: in your App's init() or in application(_:didFinishLaunchingWithOptions:). Returns at once; loading the install ID, taking links and reporting the launch with POST /v1/sdk/init happen in the background.

Prop

Type

  • Throws LanderError with code invalid_argument when apiKey, trimmed, is a secret key or not a publishable key (pk_test_ or pk_live_ followed by at least 24 letters or digits). The key is never included in the error.
  • Never throws for network errors.
  • A second call is ignored.

Lander.handle(url:)

@discardableResult
static func handle(url: URL) -> Bool

Hands a URL that opened the app to Lander: a Universal Link or a custom scheme URL. Call it from .onOpenURL, application(_:open:options:) or scene(_:openURLContexts:). Returns true for every URL with a scheme other than file. Safe to call before initialize: the URL is kept until the SDK starts.

Lander.handle(userActivity:)

@discardableResult
static func handle(userActivity: NSUserActivity) -> Bool

Hands a Universal Link to Lander, from .onContinueUserActivity(NSUserActivityTypeBrowsingWeb), application(_:continue:restorationHandler:) or scene(_:continue:). Returns true when activityType is NSUserActivityTypeBrowsingWeb and webpageURL is set.

Lander.handle(connectionOptions:)

@MainActor @discardableResult
static func handle(connectionOptions: UIScene.ConnectionOptions) -> Bool

Hands the URLs and Universal Links in a scene's connection options to Lander. Call it from scene(_:willConnectTo:options:): on a cold start, UIKit delivers the launch link there and nowhere else. Returns true when Lander took at least one link.

Lander.handle(launchOptions:)

@MainActor @discardableResult
static func handle(launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

Hands the URL (.url) or Universal Link (.userActivityDictionary) an app delegate based app was launched with to Lander. Optional: UIKit also calls application(_:open:options:) or application(_:continue:restorationHandler:) after launch, and the same URL handed over twice within 2 seconds counts once.

static var deepLinks: AsyncStream<LanderLink> { get }

Every link the app receives: Universal Links, custom scheme URLs and deferred links.

  • Each access returns a new stream. Iterate it in one task; it ends when that task is cancelled or the stream is released.
  • Safe to use at any time, even before initialize.
  • Links that arrive while no stream is listening are buffered and replayed, in order, to the next one. When several streams listen, each gets every link.
  • Includes the launch link unless initialLink() claimed it first.
  • Unknown links and links that could not be resolved are delivered with isResolved == false and only url set.
  • Does not include links returned by claimHandoff.
@discardableResult
static func onDeepLink(
  _ handler: @escaping @MainActor @Sendable (LanderLink) -> Void
) -> LanderSubscription

Calls handler on the main actor for every link, as deepLinks delivers them. The subscription lasts until you call cancel() on the returned LanderSubscription; releasing it does not end it.

static func initialLink() async -> LanderLink?

The link that launched the app, or nil. The launch link is the first link handed to handle while the app launches (until about 1 second after it first becomes active, or 5 seconds after initialize at most). On a first launch it may instead be a deferred link, so it waits for the launch report in that case. Delivered once: returns nil if deepLinks or an earlier call already delivered it, and after this call deepLinks will not deliver it.

Returns nil and logs a warning before initialize. Waiting is not cancellable: a cancelled task still gets its answer.

static func createLink(
  path: String = "/",
  params: [String: LanderParamValue] = [:],
  title: String? = nil,
  campaign: String? = nil,
  channel: String? = nil,
  tags: [String] = [],
  iosFallbackURL: URL? = nil,
  androidFallbackURL: URL? = nil,
  webFallbackURL: URL? = nil,
  ogTitle: String? = nil,
  ogDescription: String? = nil,
  ogImageURL: URL? = nil,
  expiresAt: Date? = nil
) async throws -> LanderShortLink

Creates a short link with POST /v1/sdk/links. The slug is random and the domain is the project's default domain.

Prop

Type

  • Throws LanderError (invalid_argument) when path does not start with /.
  • Throws LanderError (not_initialized) before initialize.
  • Throws LanderError when the request fails after retries, or invalid_response when the response is not a link.

See Creating links.

Lander.claimHandoff

static func claimHandoff(userId: String) async throws -> LanderLink?

Claims the link your backend bound to this user with POST /v1/handoffs, after sign in. Returns the link (isDeferred true, confidence .deterministic, method authenticated_handoff) or nil when nothing is pending. The newest pending handoff wins and every pending one for the user is cleared.

  • The link is only returned, never also delivered on deepLinks.
  • Throws LanderError (invalid_argument) when userId, trimmed, is empty or longer than 256 characters.
  • Throws LanderError when the request fails after retries, with code install_not_registered when the install could not be registered yet (the SDK retries that first), invalid_response for a response it cannot use, or not_initialized before initialize.

See Deferred links.

Lander.trackEvent

static func trackEvent(
  _ name: String,
  properties: [String: any Sendable] = [:],
  linkId: String? = nil
)

Records a custom event in the on device queue, which sends it in batches with retries. Fire and forget: returns at once, never throws. Events tracked before initialize are queued until it runs.

Prop

Type

An invalid event (bad name, a linkId that is not a UUID, properties that cannot be sent as JSON) is dropped with a warning in the log, written even when logging is off. See Events.

Lander.installID

static var installID: String? { get }

The random UUID v4 of this install (lowercase), once the SDK has started; nil before. Stored outside backups and removed on uninstall.

Lander.sdkVersion and Lander.defaultBaseURL

static let sdkVersion: String   // "0.1.0"
static let defaultBaseURL: URL  // https://api.golander.link

sdkVersion is reported to the API as sdkVersion and in the X-Lander-Sdk header (ios/0.1.0).

public struct LanderLink: Sendable, Hashable, CustomStringConvertible

A deep link delivered to the app. When Lander knows the link, the fields mirror the ResolvedLink returned by the API. When it does not (unknown link, custom scheme URL, network unavailable) only url is set and isResolved is false.

Initializers

public init(
  url: URL,
  linkId: String? = nil,
  shortURL: URL? = nil,
  path: String? = nil,
  params: [String: LanderParamValue] = [:],
  campaign: String? = nil,
  channel: String? = nil,
  isDeferred: Bool = false,
  confidence: LanderConfidence = .unattributed,
  method: String? = nil
)

/// A link Lander could not resolve. Only url is set.
public static func unresolved(_ url: URL) -> LanderLink

The public initializers make it easy to build links in your own tests. See Testing.

Properties

Prop

Type

route examples:

urlpathroute
https://acme.golander.link/p-123/product/123/product/123
https://acme.golander.link/unknownnil/unknown
acmeshop://product/123?color=rednil/product/123?color=red
acmeshop://nil/

Equality and description

LanderLink is Hashable: two links are equal when every field is equal. description gives a readable summary, for example LanderLink(<id>, path: /product/123, params: [productId: 123], url: https://acme.golander.link/p-123, deterministic via universal_link) or LanderLink(unresolved, url: acmeshop://product/123).

public struct LanderShortLink: Sendable, Hashable, CustomStringConvertible

A short link created with Lander.createLink. It has a public memberwise initializer for tests.

Prop

Type

description returns url.absoluteString.

LanderParamValue

public enum LanderParamValue: Sendable, Hashable, CustomStringConvertible,
  ExpressibleByStringLiteral, ExpressibleByIntegerLiteral,
  ExpressibleByFloatLiteral, ExpressibleByBooleanLiteral
{
  case string(String)
  case int(Int)
  case double(Double)
  case bool(Bool)
}

A link param value, as the API stores them. Literals convert on their own, so ["productId": "123", "qty": 2, "gift": true] is a [String: LanderParamValue].

AccessorTypeReturns
stringValueStringStrings as they are; numbers and booleans in their JSON form (2, 49.99, true). Also description.
intValueInt?An integer, a whole double, or a string holding an integer.
doubleValueDouble?A number, or a string holding one.
boolValueBool?A boolean, or the string true or false.

Query parameters on the opened URL always arrive as .string, so prefer the accessors over matching cases.

LanderConfidence

public enum LanderConfidence: String, Sendable, Hashable, Codable, CaseIterable {
  case deterministic, probabilistic, unattributed
}
ValueMeaning
.deterministicMatched by an exact identifier: a Universal Link open, the Continue in app page or an authenticated handoff.
.probabilisticMatched by coarse signals (OS version, country, click time, optionally a network hash) within a short window. Only iOS deferred links of projects that opted in.
.unattributedNo link could be tied to this open. Any value the SDK does not know maps to this.

LanderError

public struct LanderError: Error, Sendable, Equatable, CustomStringConvertible, LocalizedError {
  public init(code: String, message: String, statusCode: Int? = nil, retryAfter: TimeInterval? = nil)
}

Thrown by initialize (for a bad key), createLink and claimHandoff. trackEvent and the launch report never throw on network or server errors.

Prop

Type

description returns LanderError(code, statusCode): message.

API error codes you may see from the SDK endpoints: validation_error, invalid_domain, destination_blocked (400), invalid_api_key (401), wrong_key_kind, project_suspended (403), install_not_found (404), rate_limited, link_quota_exceeded (429), internal_error (500).

LanderSubscription

public final class LanderSubscription: Sendable {
  public func cancel()
}

Returned by Lander.onDeepLink. cancel() stops calling the handler. Releasing the object does not cancel it.

Network behavior

The SDK only talks to Lander's public API, never to a database.

EndpointCalled byAttempts
POST /v1/sdk/initinitialize, every launch; again on returning to the foreground, claimHandoff and event sends while no report has succeeded3 on a first launch, 1 otherwise
POST /v1/sdk/resolveEvery http or https link handed to handle, and short links carried in lander_link2
POST /v1/sdk/eventsThe event queue1 per flush; the queue retries with backoff
POST /v1/sdk/linkscreateLink3
POST /v1/sdk/handoffs/claimclaimHandoff3
  • Every request sends Authorization: Bearer <publishable key>, Content-Type: application/json and X-Lander-Sdk: ios/0.1.0, through an ephemeral URLSession.
  • Every attempt has a 10 second timeout.
  • Retries happen only for network errors, timeouts, invalid_response, 408, 429 and 5xx, with exponential backoff from 500 ms up to 4 s (or longer if Retry-After asks). One call waits at most 10 seconds in total between attempts; a longer Retry-After ends the retries. link_quota_exceeded is never retried.
  • A 2xx response must be a JSON object (a 204 may be empty), otherwise the call fails with invalid_response.
  • appVersion and osVersion are cut to 50 characters.
  • Every write carries an Idempotency-Key that stays the same across retries, so a retry never creates a second link or claim. POST /v1/sdk/init ignores the key: the API keeps one record per install ID, so a repeated launch report never creates a second install.

On this page