Generating Durable Links
Build and shorten Durable Links using the iOS SDK.
Use DurableLinkComponents to build a link with all the parameters you need, then shorten it via the API.
import AppPanel
guard let link = URL(string: "https://yourapp.com/product/123"),
var components = AppPanel.shared.durableLinks.components(
link: link,
domainURIPrefix: "https://links.yourapp.com"
) else { return }
// iOS parameters
components.iOSParameters = DurableLinkComponents.IOSParameters(bundleID: "com.yourcompany.yourapp")
components.iOSParameters?.appStoreID = "123456789"
components.iOSParameters?.minimumAppVersion = "1.0.0"
// Android parameters
components.androidParameters = DurableLinkComponents.AndroidParameters(packageName: "com.yourcompany.yourapp")
// UTM tracking
components.analyticsParameters = DurableLinkComponents.AnalyticsParameters(
source: "email",
medium: "newsletter",
campaign: "spring_sale"
)
// Social preview
components.socialMetaTagParameters = DurableLinkComponents.SocialMetaTagParameters(
title: "Check out this product",
descriptionText: "50% off for a limited time",
imageURL: URL(string: "https://yourapp.com/images/product.jpg")
)
components.shorten(.short) { url, error in
guard let shortURL = url else {
print("Error: \(error?.localizedDescription ?? "unknown")")
return
}
// https://links.yourapp.com/abc123
print(shortURL)
}
The suffix option controls the short link suffix:
| Option | Description |
|---|
.short | Short, readable suffix (e.g. abc123) |
.unguessable | Longer, random suffix that can't be guessed |
The link parameter must be a valid HTTP or HTTPS URL and cannot be another Durable Link.
| Property | Type | Description |
|---|
bundleID | String | The bundle ID of your iOS app (required) |
appStoreID | String? | Your app's App Store ID, used to send users to the App Store when the app isn't installed |
fallbackURL | URL? | URL to open if the app is not installed |
customScheme | String? | A custom URL scheme, if different from the bundle ID |
iPadBundleID | String? | A separate bundle ID for iPad, if different from iPhone |
iPadFallbackURL | URL? | Fallback URL for iPad if the iPad app is not installed |
minimumAppVersion | String? | Minimum app version required to open the link |
| Property | Type | Description |
|---|
packageName | String | The Android package name (required) |
fallbackURL | URL? | URL to open if the app is not installed |
minimumVersion | Int | Minimum version code of the Android app required to open the link |
| Property | Type | Description |
|---|
source | String? | UTM source (e.g. email) |
medium | String? | UTM medium (e.g. newsletter) |
campaign | String? | UTM campaign (e.g. spring_sale) |
term | String? | UTM term |
content | String? | UTM content |
| Property | Type | Description |
|---|
title | String? | Title for social link previews |
descriptionText | String? | Description for social link previews |
imageURL | URL? | Image URL for social link previews |
| Property | Type | Description |
|---|
forcedRedirectEnabled | Bool | When true, skip the app preview page and redirect directly |
| Property | Type | Description |
|---|
fallbackURL | URL? | URL to open on desktop or other platforms |