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
- Ensure that your App ID is correctly configured. For more information, refer to the Getting Started guide.
- Before getting started, ensure your AppLink Configuration is set up.
- Minimum supported deployment target is iOS 13.0.
Import the SDK into Your Xcode Project
Using CocoaPods
-
Close your Xcode project if it’s open.
-
In your project’s root directory, run the following command to install CocoaPods:
sudo gem install cocoapods
- Run the following command to initialize CocoaPods:
pod init
- Open the generated Podfile in your preferred code editor and add the SDK dependency under your app target:
target 'your_project_name' do
pod 'AppsOnAir-AppLink'
end
- In the terminal, navigate to your project directory and run:
pod repo update
pod install
Configure Entitlements and URL Schemes
Universal Links (Associated Domains)
- 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.

Create or update the YOUR_PROJECT.entitlements file and add the following:
<!-- 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
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:
<!-- 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>
Initialize the AppLink Service
Import the SDK at the top of your AppDelegate file or relevant Swift/SwiftUI/Objective-C file:
- Swift
- SwiftUI
- Objective-C
import AppsOnAir_AppLink
import AppsOnAir_AppLink
#import "AppsOnAir_AppLink-Swift.h"
Implementation
- Swift
- SwiftUI
- Objective-C
@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
}
}
import SwiftUI
import AppsOnAir_AppLink
@main
struct appsonairApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
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
}
}
#import "AppDelegate.h"
#import "AppsOnAir_AppLink/AppsOnAir_AppLink-Swift.h"
@interface AppDelegate ()
@property (nonatomic, strong) AppLinkService *appLinkServices;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// AppLink Class instance create
self.appLinkServices = [AppLinkService shared];
// help to initialize link services
[self.appLinkServices initializeOnDeepLinkProcessed:^(NSURL * url, NSDictionary<NSString *,id> * linkInfo) {
//Write the code for handling flow based on url
} onReferralLinkDetected:nil
onAttributionListener:^(NSDictionary<NSString *,id> * attributionInfo) {
//Write the code for handling attribution flow
}];
// Override point for customization after application launch.
return YES;
}
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
)
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.
- url
- linkInfo
- referralInfo
"https://your.deep.link"
{
"name": "AppLink",
"link": "https://your.link",
"shortId": "linkId",
"socialMetaTags": {
"description": "Description",
"imageUrl": "https://example.com",
"title": "Meta Title"
}
}
{
"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"
}
}
}
AppLink Implementation Code
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.
AppLink Creation
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.
- Swift
- SwiftUI
- Objective-C
import AppsOnAir_AppLink
import AppsOnAir_AppLink
#import "AppsOnAir_AppLink/AppsOnAir_AppLink-Swift.h"
Create the AppLink in Code
- Swift
- SwiftUI
- Objective-C
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.
}
}
struct ContentView: View {
@State private var showToast = false
@State private var message = ""
var body: some View {
VStack(spacing: 20) {
Button(action: {
AppLinkService.shared.createAppLink(
url: "https://appsonair.com",
name: "AppsOnAir",
urlPrefix: "YOUR_DOMAIN_NAME", // <urlPrefix> shouldn't contain http or https
shortId: "LINK_ID", // <shortId> If not set, it will be auto-generated
socialMeta: ["title": "link title","description": "link description","imageUrl": "https://image.png"],
isOpenInBrowserApple: false,
isOpenInIosApp: true,
iosFallbackUrl: "https://appstore.com",
appsFlyer: [ // Optional: AppsFlyer attribution params
"channel": "appsonair",
"campaignId": "01",
"campaign": "test",
"subs": ["sub1", "sub2", "sub3", "sub4", "sub5"],
"metaTitle": "metaTitle",
"metaDescription": "metaDescription"
],
attributionTtl: 3600, // Optional, in seconds
) { linkInfo in
//write the code for handling create link
}
}) {
Text("Create Link")
.padding()
.frame(maxWidth: .infinity)
.background(Color.green)
.foregroundColor(.white)
.cornerRadius(10)
}
}
.padding()
.toast(isPresented: $showToast, message: message)
.onOpenURL { url in
AppLinkService.shared.handleAppLink(incomingURL: url)
}
}
}
@interface ViewController ()
@property (nonatomic, strong) AppLinkService *appLinkService;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.appLinkService = [AppLinkService shared];
// Create a UIButton programmatically
UIButton *ctaButton = [UIButton buttonWithType:UIButtonTypeSystem];
// Set button title
[ctaButton setTitle:@"Create Link" forState:UIControlStateNormal];
// Set button frame (position and size)
ctaButton.frame = CGRectMake(100, 200, 200, 50);
// Add target-action for button tap
[ctaButton addTarget:self action:@selector(createLinkTap) forControlEvents:UIControlEventTouchUpInside];
// Add button to the view
[self.view addSubview:ctaButton];
}
- (void)createLinkTap {
// Help to create link
// <urlPrefix> shouldn't contain http or https
// <shortId> If not set, it will be auto-generated
[self.appLinkService createAppLinkWithUrl:@"https://appsonair.com" name:@"AppsOnAir" urlPrefix:@"YOUR_DOMAIN_NAME" shortId: @"LINK_ID"socialMeta:@{@"title":@"link title",@"description":@"link description",@"imageUrl":@"https://image.png"}isOpenInBrowserApple:@0 isOpenInIosApp:@1 iosFallbackUrl:@"https://appstore.com" isOpenInAndroidApp:@1 isOpenInBrowserAndroid:@0 androidFallbackUrl:@"https://play.google.com" appsFlyer:@{@"channel":@"appsonair",@"campaignId":@"01",@"campaign":@"test",@"subs":@[@"sub1",@"sub2",@"sub3",@"sub4",@"sub5"],@"metaTitle":@"metaTitle",@"metaDescription":@"metaDescription"} attributionTtl:@3600 completion:^(NSDictionary<NSString *,id> * linkInfo) {
//write the code for handling create link
}];
}
{
"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.
Parameters marked with an asterisk (*) are mandatory for successful link import.
- Objective-C
- Swift / SwiftUI
| Key | Type | Description |
|---|---|---|
| * url | String | The actual deep link URL that the app should open. Example: myapp://product/123 |
| * name | String | The name or label for the link, often used for internal identification.1–50 characters; allows letters, numbers, spaces, dots, dashes, and underscores. |
| * urlPrefix | String | The 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. |
| androidFallbackUrl | String | A web URL to redirect users to when the app is not installed on Android devices. |
| iosFallbackUrl | String | A web URL to redirect users to when the app is not installed on iOS devices. |
| shortId | String | Optional 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. |
| socialMeta | Object | Meta information used for social sharing previews. Refer to SocialMeta Properties. |
| isOpenInBrowserApple | Number | Determines whether the link should open in the browser on Apple devices (iOS/macOS). |
| isOpenInIosApp | Number | Specifies if the link should open in the iOS app even if your app is installed. |
| isOpenInAndroidApp | Number | Indicates whether to open the link in the Android app even if your app is installed. |
| isOpenInBrowserAndroid | Number | Determines if the link should open in the browser on Android devices. |
| attributionTtl | Number | Attribution window in seconds. Defaults to 3600 (1 hour); longer windows depend on your subscription plan. |
| appsFlyer | Object | AppsFlyer attribution parameters attached to the link. Refer to AppsFlyerParams Properties. |
| Key | Type | Description |
|---|---|---|
| * url | String | The actual deep link URL that the app should open. Example: myapp://product/123 |
| * name | String | The name or label for the link, often used for internal identification.1–50 characters; allows letters, numbers, spaces, dots, dashes, and underscores. |
| * urlPrefix | String | The 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. |
| androidFallbackUrl | String | A web URL to redirect users to when the app is not installed on Android devices. |
| iosFallbackUrl | String | A web URL to redirect users to when the app is not installed on iOS devices. |
| shortId | String | Optional 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. |
| socialMeta | Object | Meta information used for social sharing previews. Refer to SocialMeta Properties. |
| isOpenInBrowserApple | Boolean | Determines whether the link should open in the browser on Apple devices (iOS/macOS). |
| isOpenInIosApp | Boolean | Specifies if the link should open in the iOS app even if your app is installed. |
| isOpenInAndroidApp | Boolean | Indicates whether to open the link in the Android app even if your app is installed. |
| isOpenInBrowserAndroid | Boolean | Determines if the link should open in the browser on Android devices. |
| attributionTtl | Number | Attribution window in seconds. Defaults to 3600 (1 hour); longer windows depend on your subscription plan. |
| appsFlyer | Object | AppsFlyer attribution parameters attached to the link. Refer to AppsFlyerParams Properties. |
SocialMeta Properties
Defines all social meta parameters used during AppLink creation.
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.
| Key | Type | Description |
|---|---|---|
| title | String | The title to show in social media link previews. |
| description | String | A short description used in social sharing cards (Facebook, Twitter, etc.). |
| imageUrl | String | A URL to an image that will appear in the social media preview. |
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.
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.
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.
All AppsFlyer fields are optional. Links created without them keep their existing behavior.
| Key | Type | Description |
|---|---|---|
| channel | String | The media source or channel driving traffic to this link. Maximum 20 characters. Example: appsonair |
| campaignId | String | Unique identifier for the marketing campaign. Maximum 24 characters. |
| campaign | String | Human-readable name of the marketing campaign. Maximum 100 characters. |
| subs | String[] | 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"] |
| metaTitle | String | Title shown on the Android redirection page. |
| metaDescription | String | Description 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 Example | Status | API Result |
|---|---|---|
"isOpenInBrowserAndroid": true, "isOpenInAndroidApp": true | Invalid | Either isOpenInBrowserAndroid or isOpenInAndroidApp must be true. Not both. Configure Android redirection using only one of them. |
"isOpenInBrowserAndroid": true, "isOpenInAndroidApp": false | Success | Success link creation response will be returned. |
"isOpenInBrowserAndroid": false, "isOpenInAndroidApp": true | Success | Success link creation response will be returned. |
"isOpenInBrowserAndroid": false, "isOpenInAndroidApp": false | Invalid | At 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) | Invalid | Android App is not configured for this URL Prefix. Please configure the Android App to handle AppLink redirection in Android. |
"isOpenInBrowserApple": true, "isOpenInIosApp": true | Invalid | Either isOpenInBrowserApple or isOpenInIosApp must be true. Not both. Configure iOS redirection using only one of them. |
"isOpenInBrowserApple": true, "isOpenInIosApp": false | Success | Success link creation response will be returned. |
"isOpenInBrowserApple": false, "isOpenInIosApp": true | Success | Success link creation response will be returned. |
"isOpenInBrowserApple": false, "isOpenInIosApp": false | Invalid | At 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) | Invalid | iOS App is not configured for this URL Prefix. Please configure the iOS App to handle AppLink redirection in iOS. |
- 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.
Get App Link Info
Use getAppLinkInfo() to fetch link details on demand. Only returns data for links belonging to your configured AppsonairAppId.
Both shortId and urlPrefix are required.
- Swift
- SwiftUI
- Objective-C
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
}
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
}
#import "AppsOnAir_AppLink/AppsOnAir_AppLink-Swift.h"
[self.appLinkService getAppLinkInfoWithShortId:@"LINK_SHORT_ID"
urlPrefix:@"YOUR_DOMAIN_NAME" // shouldn't contain http or https
completion:^(NSDictionary<NSString *, id> *info) {
// Handle link info
}];
{
"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
Parameters marked with an asterisk (*) are mandatory.
| Key | Type | Description |
|---|---|---|
| * shortId | String | The short identifier of the link — the last path segment of the link URL. Example: abc123 |
| * urlPrefix | String | The 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.
- Swift
- SwiftUI
- Objective-C
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
}
}
}
import AppsOnAir_AppLink
struct ContentView: View {
var body: some View {
Button(action: {
AppLinkService.shared.getAttributionInfo { attributionInfo in
//Write the code for handling attributionInfo
}
}) {
Text("Fetch Attribution Info")
.padding()
.frame(maxWidth: .infinity)
.background(Color.green)
.foregroundColor(.white)
.cornerRadius(10)
}
.padding()
}
}
#import "AppsOnAir_AppLink/AppsOnAir_AppLink-Swift.h"
@interface ViewController ()
@property (nonatomic, strong) AppLinkService *appLinkService;
@end
@implementation ViewController
- (void)getAttributionInfoTap {
// Retrieve attribution info
[self.appLinkService getAttributionInfoWithCompletion:^(NSDictionary<NSString *,id> * attributionInfo) {
//Write the code for handling attributionInfo
}];
}
@end
{
"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.
| Key | Type | Description |
|---|---|---|
appsFlyer | Object | The 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. |
isFirstLaunch | Boolean | true 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. |
firstInstallTime | Number | Timestamp 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_time | Number | Timestamp of the click, in epoch milliseconds. Present only when the Advanced Deferred AppLink feature is enabled. |
isConsumed | Boolean | true once a referral fetch has returned successfully for this install, within that same session. Persisted, so it stays true on every later launch. |
attributionStatus | String | non-organic when the install happened within attributionTtl seconds of the click, otherwise organic. |
attributionTtl | Number | The attribution window configured for the link, in seconds. |
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.
Get Referral Link (Deprecated)
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.
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.
| Deprecated | Use 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.
- Swift
- SwiftUI
- Objective-C
import AppsOnAir_AppLink
import AppsOnAir_AppLink
#import "AppsOnAir_AppLink/AppsOnAir_AppLink-Swift.h"
Get Referral Link in Code
getReferralInfo(): Returns the same referral data that was initially received and will continue to return it until the app is uninstalled.
- Swift
- SwiftUI
- Objective-C
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.
}
}
struct ContentView: View {
var body: some View {
VStack(spacing: 20) {
Button(action: {
AppLinkService.shared.getReferralInfo { linkInfo in
//Write the code for handling referral flow based on url
}
}) {
Text("Fetch Referral Link")
.padding()
.frame(maxWidth: .infinity)
.background(Color.green)
.foregroundColor(.white)
.cornerRadius(10)
}
}
.padding()
.onOpenURL { url in
AppLinkService.shared.handleAppLink(incomingURL: url)
}
}
}
@interface ViewController ()
@property (nonatomic, strong) AppLinkService *appLinkService;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.appLinkService = [AppLinkService shared];
// Create a UIButton programmatically
UIButton *ctaButton = [UIButton buttonWithType:UIButtonTypeSystem];
// Set button title
[ctaButton setTitle:@"Fetch Referral Link" forState:UIControlStateNormal];
// Set button frame (position and size)
ctaButton.frame = CGRectMake(100, 200, 200, 50);
// Add target-action for button tap
[ctaButton addTarget:self action:@selector(getReferralLinkTap) forControlEvents:UIControlEventTouchUpInside];
// Add button to the view
[self.view addSubview:ctaButton];
}
- (void)getReferralLinkTap {
// Retrieve referral link info
[self.appLinkServices getReferralInfoWithCompletion:^(NSDictionary<NSString *,id> * linkInfo) {
//Write the code for handling referral linkInfo
}];
}
{
"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"
}
}
}
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
Note: If you call getReferralDetails() immediately after initialization, you may need to add a short delay to ensure the referral data is available.
- Swift
- SwiftUI
- Objective-C
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.
}
}
struct ContentView: View {
var body: some View {
VStack(spacing: 20) {
Button(action: {
// If you call getReferralDetails immediately after initialization, you may need to add a short delay to ensure the referral data is available.
AppLinkService.shared.getReferralDetails { linkInfo in
//write the code for handling referral linkInfo
}
}) {
Text("Fetch Referral Link")
.padding()
.frame(maxWidth: .infinity)
.background(Color.green)
.foregroundColor(.white)
.cornerRadius(10)
}
}
.padding()
.onOpenURL { url in
AppLinkService.shared.handleAppLink(incomingURL: url)
}
}
}
@interface ViewController ()
@property (nonatomic, strong) AppLinkService *appLinkService;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.appLinkService = [AppLinkService shared];
// Create a UIButton programmatically
UIButton *ctaButton = [UIButton buttonWithType:UIButtonTypeSystem];
// Set button title
[ctaButton setTitle:@"Fetch Referral Link" forState:UIControlStateNormal];
// Set button frame (position and size)
ctaButton.frame = CGRectMake(100, 200, 200, 50);
// Add target-action for button tap
[ctaButton addTarget:self action:@selector(getReferralLinkTap) forControlEvents:UIControlEventTouchUpInside];
// Add button to the view
[self.view addSubview:ctaButton];
}
- (void)getReferralLinkTap {
// 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.
[self.appLinkService getReferralDetailsWithCompletion:^(NSDictionary<NSString *,id> * linkInfo) {
//write the code for handling referral linkInfo
}];
}
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
- Swift
- Objective-C
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
}
}
@interface AppDelegate ()
@property (nonatomic, strong) AppLinkService *appLinkServices;
@end
- (BOOL)application:(UIApplication _ )application didFinishLaunchingWithOptions:(NSDictionary _)launchOptions {
self.appLinkServices = [AppLinkService shared];
return YES;
}
- (BOOL)application:(UIApplication _)application
openURL:(NSURL _)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> \*)options {
[self.appLinkServices handleAppLinkWithIncomingURL:url];
return YES;
}
- (BOOL)application:(UIApplication _)application
continueUserActivity:(NSUserActivity _)userActivity
restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> \* \_Nullable))restorationHandler {
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *url = userActivity.webpageURL;
[self.appLinkServices handleAppLinkWithIncomingURL:url];
}
return NO;
}
SceneDelegate Setup
- Swift
- Objective-C
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)
}
}
@interface SceneDelegate ()
@property (nonatomic, strong) AppLinkService *appLinkServices;
@end
@implementation SceneDelegate
- (void)scene:(UIScene *)scene
willConnectToSession:(UISceneSession *)session
options:(UISceneConnectionOptions *)connectionOptions {
// Handle URLs when app is cold started
if (connectionOptions.URLContexts.count > 0) {
UIOpenURLContext *urlContext = connectionOptions.URLContexts.allObjects.firstObject;
NSURL *url = urlContext.URL;
if (url) {
[self.appLinkServices handleAppLinkWithIncomingURL:url];
}
}
// Handle Universal Link via user activity when app is cold started
if (connectionOptions.userActivities.count > 0) {
NSUserActivity *userActivity = connectionOptions.userActivities.allObjects.firstObject;
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *url = userActivity.webpageURL;
if (url) {
[self.appLinkServices handleAppLinkWithIncomingURL:url];
}
}
}
self.appLinkServices = [AppLinkService shared];
UIWindowScene *windowScene = (UIWindowScene *)scene;
self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
// Set root view controller
self.window.rootViewController = [[ViewController alloc] init];
[self.window makeKeyAndVisible];
}
- (void)scene:(UIScene *)scene continueUserActivity:(NSUserActivity *)userActivity {
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSURL *incomingURL = userActivity.webpageURL;
if (incomingURL) {
[self.appLinkServices handleAppLinkWithIncomingURL:incomingURL];
}
}
}
- (void)scene:(UIScene *)scene openURLContexts:(NSSet<UIOpenURLContext *> *)URLContexts {
UIOpenURLContext *urlContext = [URLContexts anyObject];
if (urlContext) {
NSURL *url = urlContext.URL;
[self.appLinkServices handleAppLinkWithIncomingURL:url];
}
}
@end
- 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 App & Verify AppLink services
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