A Swift library for handling deferred deep links on iOS. This SDK allows your app to identify what link it was installed from and handle Universal Links appropriately.
- Detect new app installations
- Handle Universal Links
- Retrieve attribution tokens from StoreKit
- Process deferred deep links
- Route to appropriate screens in your app
- Integration with Linklab Redirector service
- iOS 14.0+
- Swift 5.0+
- Xcode 13.0+
The Linklab SDK can be installed via Swift Package Manager. Add the following to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/your-organization/linklab-ios-sdk.git", from: "1.0.0")
]
Or add it directly in Xcode using File > Add Packages.
Initialize the SDK in your AppDelegate or SceneDelegate:
import Linklab
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize Linklab
let config = Configuration(
debugLoggingEnabled: true
)
Linklab.shared.initialize(with: config) { destination in
if let destination = destination {
// Handle deep link destination
navigateToDestination(destination)
}
}
return true
}
// Helper method to navigate to the deep link destination
func navigateToDestination(_ destination: LinkDestination) {
// Handle routing based on destination.route and destination.parameters
// For example:
switch destination.route {
case "products":
if let productId = destination.parameters["id"] {
navigateToProduct(productId)
}
case "categories":
if let categoryId = destination.parameters["id"] {
navigateToCategory(categoryId)
}
default:
// Handle unknown routes or navigate to home screen
break
}
}
Implement the following method in your SceneDelegate:
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
if userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL {
Linklab.shared.handleUniversalLink(url)
}
}
- Configure your app for Universal Links by adding the Associated Domains capability
- Add the appropriate domain to your entitlements file
- Set up the
apple-app-site-association
file on your server
The Linklab iOS SDK works with the Linklab Redirector service at https://linklab.cc
according to its OpenAPI specification. The API URL is hardcoded in the SDK, so you don't need to provide it during initialization.
The SDK communicates with the /apple-attribution
endpoint to process Apple attribution tokens for deferred deep linking:
- Endpoint: POST https://linklab.cc/apple-attribution
- Request Body:
{ "attributionToken": "token-from-apple" }
- Response: The SDK processes the Link data returned by the API, extracting both the link properties and any query parameters from the full URL to create a LinkDestination object.
This integration enables:
- First-launch attribution tracking
- Deferred deep linking to specific content
- Parameter passing from acquisition links to the app
See the LICENSE file for details.