Skip to main content

iOS SDK Setup

AppsOnAir AppLink helps you manage deep links and in-app routing seamlessly in your iOS app. With a simple integration, you can configure, manage, and respond to links either from the web dashboard or directly through the mobile app SDK in real time.

To integrate the AppsOnAir AppLink iOS SDK into your native iOS apps, follow the steps below or watch the full video tutorial.

Basic Requirements​

Essential Setup
  • Ensure that your App ID is correctly configured. For more information, refer to the Getting Started guide.
Prerequisites
  • Minimum supported deployment target is iOS 13.0.

Import the SDK into Your Xcode Project​

Using CocoaPods​

  1. Close your Xcode project if it’s open.

  2. In your project’s root directory, run the following command to install CocoaPods:

Terminal
sudo gem install cocoapods
  1. Run the following command to initialize CocoaPods:
Terminal
pod init
  1. Open the generated Podfile in your preferred code editor and add the SDK dependency under your app target:
Podfile
target 'your_project_name' do
pod 'AppsOnAir-AppLink'
end
  1. In the terminal, navigate to your project directory and run:
Terminal
pod repo update
pod install

Configure Entitlements and URL Schemes​

Note
  • Configuring associated domains is optional.

To support Universal Links, create or edit the YOUR_PROJECT.entitlements file and add the following configuration:

  • In Xcode, Under TARGETS, select your app target (usually the one named after your app).
  • At the top, select the Signing & Capabilities tab.
  • Click the + Capability button in the top-left corner of that section.
  • In the list of capabilities, scroll or search to select Associated Domains.
  • This will automatically create a file named YOUR_PROJECT.entitlements.

Associated Domains

Create or update the YOUR_PROJECT.entitlements file and add the following:

YOUR_PROJECT.entitlements
<!-- If Using Universal Links -->
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:YOUR_DOMAIN</string> <!-- Replace with your actual domain -->
</array>

Add/Update Associated Domain​

Docusaurus logo

Note

After configuring the Associated Domain for Universal Links, it may take up to 24 hours for the changes to be reflected and become active. The Associated Domain setup and verification process is managed by Apple.

Custom URL Scheme​

If you're using a Custom URL scheme, update your app’s Info.plist file with the following:

Info.plist
<!-- If Using Custom Url Schema -->
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>YOUR_URL_NAME</string>
<key>CFBundleURLSchemes</key>
<array>
<string>YOUR_CUSTOM_URL_SCHEME</string> <!-- Replace with your custom URL scheme -->
</array>
</dict>
</array>

Import the SDK at the top of your AppDelegate file or relevant Swift/SwiftUI/Objective-C file:

AppDelegate.swift
import AppsOnAir_AppLink

Implementation​

AppDelegate.swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
// AppLink Class instance create
let appLinkService = AppLinkService.shared

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Initialize the link service
AppLinkService.shared.initialize { url, linkInfo in
//Write the code for handling flow based on url
} onAttributionListener: { attributionInfo in
//Write the code for handling attribution flow
}
return true
}

}

initialize takes a single signature. onReferralLinkDetected and onAttributionListener are both optional:

initialize(
onDeepLinkProcessed: (URL?, [String: Any]) -> Void,
onReferralLinkDetected: (([String: Any]) -> Void)? = nil,
onAttributionListener: (([String: Any]) -> Void)? = nil
)
info

onAttributionListener is new in 2.0.0 and is the only addition to initialize, which keeps the single listener it has always had. Existing integrations compile unchanged.

Prefer onAttributionListener over onReferralLinkDetected, which will be deprecated in a future release.

Response
"https://your.deep.link"
Important

When using SwiftUI, it is necessary to add the .onOpenURL modifier in ContentView.swift, directly after any layout container such as VStack, Button, or similar views for handling AppLink.

VStack {
// Your UI components here
}
.onOpenURL { url in
AppLinkService.shared.handleAppLink(incomingURL: url)
}
  • The initialize() function initializes the common AppLink service and sets up the deep link handler. It processes the incoming link when the app is launched with any URL.

You can also generate a AppLink such as from a button tap within your application’s UI.

Import the SDK​

Import the AppsOnAir_AppLink module into your ViewController or relevant Swift/SwiftUI/Objective-C file.

ViewController.swift
import AppsOnAir_AppLink
ViewController.swift
class ViewController: UIViewController {
let appLinkService = AppLinkService.shared

override func viewDidLoad() {
super.viewDidLoad()

let button = UIButton(type: .system)
button.setTitle("Button", for: .normal)
button.backgroundColor = .systemBlue
button.setTitleColor(.white, for: .normal)
button.layer.cornerRadius = 10

// Set button frame (size and position)
button.frame = CGRect(x: 100, y: 200, width: 150, height: 50)

// Add target for onPressed (TouchUpInside)
button.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)

// Add the button to the view
self.view.addSubview(button)
}

// Define the action when button is pressed
@objc func buttonPressed() {
// Help to create the link
// <urlPrefix> shouldn't contain http or https
// <shortId> If not set, it will be auto-generated
// appsFlyer and attributionTtl are optional
appLinkService.createAppLink(url: "https://appsonair.com",name: "AppsOnAir",urlPrefix: "YOUR_DOMAIN_NAME",shortId: "LINK_ID",socialMeta: ["title": "link title","description": "link description","imageUrl": "https://image.png"],isOpenInBrowserApple: false,isOpenInIosApp: true,iosFallbackUrl: "https://appstore.com",appsFlyer: ["channel": "appsonair","campaignId": "01","campaign": "test","subs": ["sub1", "sub2", "sub3", "sub4", "sub5"],"metaTitle": "metaTitle","metaDescription": "metaDescription"],attributionTtl: 3600
) { linkInfo in
//write the code for handling create link
}
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Response
{
"data": {
"shortUrl": "https://appsonair.link/shortId"
},
"message": "AppLink created successfully!",
"status": "SUCCESS"
}

AppLinkParams Properties​

Defines all parameters used to construct a AppLink, including app URL, fallbacks, short ID, and social-meta.

Note:

Parameters marked with an asterisk (*) are mandatory for successful link import.

KeyTypeDescription
* urlStringThe actual deep link URL that the app should open. Example: myapp://product/123
* nameStringThe name or label for the link, often used for internal identification.1–50 characters; allows letters, numbers, spaces, dots, dashes, and underscores.
* urlPrefixStringThe base URL prefix for the link Example: app.domain.com. This helps create a complete shareable link.Only letters, numbers, hyphens, and underscores are allowed (max 50 chars). shouldn't contain http or https.
androidFallbackUrlStringA web URL to redirect users to when the app is not installed on Android devices.
iosFallbackUrlStringA web URL to redirect users to when the app is not installed on iOS devices.
shortIdStringOptional short ID for a shorter and easier share link. If not set, it will be auto-generated.1–50 characters. allows letters, numbers, hyphens, and underscores.
socialMetaObjectMeta information used for social sharing previews. Refer to SocialMeta Properties.
isOpenInBrowserAppleNumberDetermines whether the link should open in the browser on Apple devices (iOS/macOS).
isOpenInIosAppNumberSpecifies if the link should open in the iOS app even if your app is installed.
isOpenInAndroidAppNumberIndicates whether to open the link in the Android app even if your app is installed.
isOpenInBrowserAndroidNumberDetermines if the link should open in the browser on Android devices.
attributionTtlNumberAttribution window in seconds. Defaults to 3600 (1 hour); longer windows depend on your subscription plan.
appsFlyerObjectAppsFlyer attribution parameters attached to the link. Refer to AppsFlyerParams Properties.

SocialMeta Properties​

Defines all social meta parameters used during AppLink creation.

info

All social meta fields are optional. If left blank, the title, image, and description will be automatically fetched from the Deep Link URL (url parameter) you provided during AppLink creation.

KeyTypeDescription
titleStringThe title to show in social media link previews.
descriptionStringA short description used in social sharing cards (Facebook, Twitter, etc.).
imageUrlStringA URL to an image that will appear in the social media preview.
tip

Some platforms do not support WebP images for link previews, which may cause the preview image to not appear. For best compatibility, always use PNG or JPG images for the Preview Image URL (Web Portal) or imageUrl parameter (SDK).

Attribution Window (attributionTtl)​

attributionTtl controls how long after a link click an install can still be attributed to that link. You set it per link when the link is created.

It defaults to 1 hour (3600 seconds). Longer attribution windows depend on your subscription plan — to request one, reach out to our support team at [email protected].

An install that happens within this window is reported as non-organic. Once the window has passed, the click is no longer treated as the referral for that install, and the attribution is reported as organic.

note

If the link also carries AppsFlyer data, AppsFlyer accepts the attribution window only in whole hours. A window that includes minutes is rounded down to the nearest hour on the AppsFlyer side, so 9000 seconds (2 hours 30 minutes) reaches AppsFlyer as 2 hours. The AppLink attribution itself still uses the full value you set. See AppsFlyer Attribution.

important

The attribution window works only when Advanced Deferred AppLink is enabled.

AppsFlyerParams Properties​

Defines the AppsFlyer attribution parameters attached to the link during AppLink creation.

info

All AppsFlyer fields are optional. Links created without them keep their existing behavior.

KeyTypeDescription
channelStringThe media source or channel driving traffic to this link. Maximum 20 characters. Example: appsonair
campaignIdStringUnique identifier for the marketing campaign. Maximum 24 characters.
campaignStringHuman-readable name of the marketing campaign. Maximum 100 characters.
subsString[]Sub-parameters for granular tracking. Up to 5 values, 100 characters each. If not provided, the link's shortId is used as sub1. Example: ["sub1", "sub2", "sub3", "sub4", "sub5"]
metaTitleStringTitle shown on the Android redirection page.
metaDescriptionStringDescription shown on the Android redirection page.

Redirection Validation Rules​

This table outlines valid and invalid redirection configurations for Android and iOS platforms. All fields are optional, but if provided, they must be configured correctly to ensure proper redirection behavior and successful link creation.

Configuration ExampleStatusAPI Result
"isOpenInBrowserAndroid": true, "isOpenInAndroidApp": trueInvalidEither isOpenInBrowserAndroid or isOpenInAndroidApp must be true. Not both. Configure Android redirection using only one of them.
"isOpenInBrowserAndroid": true, "isOpenInAndroidApp": falseSuccessSuccess link creation response will be returned.
"isOpenInBrowserAndroid": false, "isOpenInAndroidApp": trueSuccessSuccess link creation response will be returned.
"isOpenInBrowserAndroid": false, "isOpenInAndroidApp": falseInvalidAt least one of the properties isOpenInBrowserAndroid or isOpenInAndroidApp must be set to true for Android redirection. Please update one.
"isOpenInBrowserAndroid": false, "isOpenInAndroidApp": true (Android App not configured in AppLink URL Prefix)InvalidAndroid App is not configured for this URL Prefix. Please configure the Android App to handle AppLink redirection in Android.
"isOpenInBrowserApple": true, "isOpenInIosApp": trueInvalidEither isOpenInBrowserApple or isOpenInIosApp must be true. Not both. Configure iOS redirection using only one of them.
"isOpenInBrowserApple": true, "isOpenInIosApp": falseSuccessSuccess link creation response will be returned.
"isOpenInBrowserApple": false, "isOpenInIosApp": trueSuccessSuccess link creation response will be returned.
"isOpenInBrowserApple": false, "isOpenInIosApp": falseInvalidAt least one of the properties isOpenInBrowserApple or isOpenInIosApp must be set to true for iOS redirection. Please update one.
"isOpenInBrowserApple": false, "isOpenInIosApp": true (iOS App not configured in AppLink URL Prefix)InvalidiOS App is not configured for this URL Prefix. Please configure the iOS App to handle AppLink redirection in iOS.
NOTE
  • If Android or iOS redirection parameters are provided but the corresponding app is not configured for the specified urlPrefix, an error will be returned: App configuration missing. Please configure the Android or iOS app for this URL Prefix to enable redirection.

Use getAppLinkInfo() to fetch link details on demand. Only returns data for links belonging to your configured AppsonairAppId. Both shortId and urlPrefix are required.

ViewController.swift
import AppsOnAir_AppLink

AppLinkService.shared.getAppLinkInfo(
shortId: "LINK_SHORT_ID",
urlPrefix: "YOUR_DOMAIN_NAME" // shouldn't contain http or https
) { info in
// Handle link info
}
Response
{
"data": {
"name": "Link Name",
"link": "https://example.com/target-page",
"shortId": "LINK_SHORT_ID",
"socialMetaTags": {
"title": "Link Title",
"description": "Link Description",
"imageUrl": "https://example.com/image.png"
},
"attributionTtl": 3600,
"appsFlyer": {
"channel": "appsonair",
"campaignId": "01",
"campaign": "test",
"subs": ["sub1", "sub2", "sub3", "sub4", "sub5"],
"metaTitle": "metaTitle",
"metaDescription": "metaDescription"
}
},
"message": "AppLink fetched successfully!",
"status": "SUCCESS"
}

appsFlyer is included only when the link was created with AppsFlyer params.

GetAppLinkInfo Parameters​

Note:

Parameters marked with an asterisk (*) are mandatory.

KeyTypeDescription
* shortIdStringThe short identifier of the link — the last path segment of the link URL. Example: abc123
* urlPrefixStringThe domain of the link, without scheme. Example: app.domain.com

Get Attribution Info​

To get the attribution information for the current install, you can call the getAttributionInfo() method from a button action or wherever you need it. It returns the referral details together with the attribution fields, and replaces the deprecated getReferralInfo() and getReferralDetails() methods.

To be notified when the attribution is detected instead of reading it on demand, use the onAttributionListener closure passed to initialize, as shown in Initialize the AppLink Service.

ViewController.swift
import AppsOnAir_AppLink

class ViewController: UIViewController {

// Define the action when button is pressed
@objc func buttonPressed() {
// Retrieve attribution info
AppLinkService.shared.getAttributionInfo { attributionInfo in
//Write the code for handling attributionInfo
}
}
}
Response
{
"message": "Referral link fetched successfully!",
"status": "SUCCESS",
"data": {
"link": "https://your.link",
"name": "AppLink",
"referralLink": "https://your.referral.link",
"shortId": "linkId",
"socialMetaTags": {
"description": "Description",
"imageUrl": "https://example.com",
"title": "Meta Title"
},
"appsFlyer": {
"channel": "appsonair",
"campaignId": "01",
"campaign": "test",
"subs": ["sub1", "sub2", "sub3", "sub4", "sub5"],
"metaTitle": "metaTitle",
"metaDescription": "metaDescription"
},
"isFirstLaunch": true,
"firstInstallTime": 1787136029546, // Number (epoch ms)
"applink_click_time": 1787135812430, // Number (epoch ms)
"isConsumed": true,
"attributionStatus": "non-organic",
"attributionTtl": 3600
}
}

Attribution Fields​

getAttributionInfo() and onAttributionListener add the following keys inside the data object, alongside the referral details.

KeyTypeDescription
appsFlyerObjectThe AppsFlyer attribution parameters attached to the link when it was created. Returned only on the attribution APIs, and only for links that carry them. The key may sit inside data or at the root of the response.
isFirstLaunchBooleantrue only during the first app launch after installation. It turns false as soon as the app leaves the foreground, and stays false on every later launch.
firstInstallTimeNumberTimestamp of the app's first installation, in epoch milliseconds. Derived from the app's Documents directory creation date, so it is always available.
applink_click_timeNumberTimestamp of the click, in epoch milliseconds. Present only when the Advanced Deferred AppLink feature is enabled.
isConsumedBooleantrue once a referral fetch has returned successfully for this install, within that same session. Persisted, so it stays true on every later launch.
attributionStatusStringnon-organic when the install happened within attributionTtl seconds of the click, otherwise organic.
attributionTtlNumberThe attribution window configured for the link, in seconds.
caution

onAttributionListener fires at most twice: once when the attribution is detected, and once more on the first return to the foreground after isFirstLaunch has turned false, so the listener sees that change. Later returns to the foreground do not fire it.

Some attribution behavior differs between Android and iOS. The values described above are the iOS behavior.

To get the AppLink referral information, you can call the getReferralInfo() method, You can also retrieving linkInfo, such as from a button action or wherever you need it.

Deprecated

The referral getters on this page are deprecated as of SDK 2.0.0. They continue to work, so existing integrations keep functioning, but new integrations should use the attribution APIs instead.

DeprecatedUse instead
getReferralInfo()getAttributionInfo()
getReferralDetails()getAttributionInfo()

They carry the referral payload only. None of appsFlyer, isFirstLaunch, firstInstallTime, isConsumed, attributionStatus or applink_click_time appear in them — those belong to getAttributionInfo() and onAttributionListener.

onReferralLinkDetected is not deprecated yet, but it will be in a future release — use onAttributionListener instead. It remains detection only: it fires when a referral fetch actually runs — first open, or no referral cached yet — and is not re-delivered on the foreground return that follows isFirstLaunch turning false.

Import the SDK​

Import the AppsOnAir_AppLink module into your ViewController.swift or relevant Swift/Objective-C file.

ViewController.swift
import AppsOnAir_AppLink

getReferralInfo(): Returns the same referral data that was initially received and will continue to return it until the app is uninstalled.

ViewController.swift
class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

let button = UIButton(type: .system)
button.setTitle("Button", for: .normal)
button.backgroundColor = .systemBlue
button.setTitleColor(.white, for: .normal)
button.layer.cornerRadius = 10

// Set button frame (size and position)
button.frame = CGRect(x: 100, y: 200, width: 150, height: 50)

// Add target for onPressed (TouchUpInside)
button.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)

// Add the button to the view
self.view.addSubview(button)
}

// Define the action when button is pressed
@objc func buttonPressed() {
// Retrieve referral link info
AppLinkService.shared.getReferralInfo { linkInfo in
//Write the code for handling referral linkInfo
}
}


override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

}
Response
{
"message": "Referral link fetched successfully!",
"status": "SUCCESS",
"data": {
"link": "https://your.link",
"name": "AppLink",
"referralLink": "https://your.referral.link",
"shortId": "linkId",
"socialMetaTags": {
"description": "Description",
"imageUrl": "https://example.com",
"title": "Meta Title"
}
}
}
Advanced Deferred AppLink

Due to Apple’s privacy changes and the Private Relay feature from iOS 15, referral data may not always be available.see the Advanced Referral Link For a smooth user experience, please refer to the Advanced Referral Link documentation.

Deprecated getReferralDetails method​

Deprecation

Note: If you call getReferralDetails() immediately after initialization, you may need to add a short delay to ensure the referral data is available.

ViewController.swift
class ViewController: UIViewController {
let appLinkService = AppLinkService.shared

override func viewDidLoad() {
super.viewDidLoad()

let button = UIButton(type: .system)
button.setTitle("Button", for: .normal)
button.backgroundColor = .systemBlue
button.setTitleColor(.white, for: .normal)
button.layer.cornerRadius = 10

// Set button frame (size and position)
button.frame = CGRect(x: 100, y: 200, width: 150, height: 50)

// Add target for onPressed (TouchUpInside)
button.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)

// Add the button to the view
self.view.addSubview(button)
}

// Define the action when button is pressed
@objc func buttonPressed() {
// Retrieve referral link info
// If you call getReferralDetails immediately after initialization, you may need to add a short delay to ensure the referral data is available.
appLinkService.getReferralDetails { linkInfo in
//write the code for handling referral linkInfo
}
}


override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

}

Troubleshooting​

If your app isn’t handling Universal Links or Deep Links as expected, ensure that you’ve correctly implemented the required delegate methods in both AppDelegate and SceneDelegate.

AppDelegate Setup​

AppDelegate.swift
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?
let appLinkService = AppLinkService.shared

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL else {
return false
}
appLinkService.handleAppLink(incomingURL: url)
return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
appLinkService.handleAppLink(incomingURL: url)
return true
}
}

SceneDelegate Setup​

SceneDelegate.swift
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
let appLinkService = AppLinkService.shared
var window: UIWindow?

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let urlContext = URLContexts.first else { return }
let url = urlContext.url
appLinkService.handleAppLink(incomingURL: url)
}
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let incomingURL = userActivity.webpageURL else {
return
}
appLinkService.handleAppLink(incomingURL: incomingURL)
}
}
Referral Testing
  • Click the referral link, it should redirect you to the App Store.
  • To retrieve the latest referral data, you must uninstall the app, then reinstall it, and fetch the referral again.

Run your app by using Xcode on iOS simulators or any physical device to make sure it builds correctly.

Video Tutorial​

To understand how to set up and integrate AppLink for Android, watch the full walkthrough video below: Watch the tutorial

For more details explore the example​