Overview
This guide provides instructions for configuring deep linking in your iOS application using the AppTrove iOS SDK. Deep linking directs users to specific in-app content using Universal Links (e.g., https://yourbrand.u9ilnk.me
), enhancing user experience and engagement.
Prerequisites
- iOS 10.0 or later and Xcode 12.0 or later
- Access to the Trackier Panel and Apple Developer Account
- Basic knowledge of Swift and iOS development
Deep Linking
Deep linking uses Universal Links to open your app directly and navigate users to specific content, such as a product page or user profile. Configuring Universal Links involves setting up your app in the Trackier Panel, Apple Developer Account, and Xcode.
Step 1: Get the App Bundle ID and Prefix ID
- Log in to your Apple Developer Account.
- On the left-hand menu, select Certificates, IDs & Profiles.
- Under Identifiers, select App IDs.
- Click the relevant app.
- Copy the Prefix ID and App Bundle ID for use in the Trackier Panel.
Step 2: Add Prefix ID and App Bundle ID in Trackier MMP
- Log in to your Trackier Panel.
- Select your application, click the Action button, and log in.
- In the Dashboard, click the UniLink option on the left side of the panel.
- On the UniLink page, create a template by clicking the Action button located on the right side header of the page.
- Edit the template by clicking the Edit button.
- On the edit template page, add the Prefix ID and App Bundle ID in the Link Behaviour (When application is installed) section.
Refer to the screenshot in the Trackier Panel for visual reference when configuring the UniLink template.
Step 3: Configure Mobile Apps to Register Associated Domains
To enable Universal Links, configure your app in Xcode to register the UniLink subdomain provided by Trackier.
- Get the UniLink subdomain from the app settings page in the Trackier Panel.
- In Xcode, click on your project and select the project target.
- Switch to the Capabilities tab.
- Turn on Associated Domains.
- Add the UniLink subdomain in the format
applinks:trackier.unilink.me
(e.g.,applinks:yourbrand.unilink.me
).
Additional Notes
- Trackier hosts the
apple-app-site-association
file for your UniLink domain. - When a user installs your app, iOS attempts to download the associated domain file to verify the domains in your app's Associated Domains Entitlement.
Step 4: Handle Deep Links in Your App
Parse Deep Link Manually If you receive a deep link (e.g., from application(_:open:options:)), you can manually trigger parsing
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
TrackierSDK.parseDeepLink(uri: url.absoluteString)
return true
}
To retrieve and process deep linking URLs, implement the DeepLinkListener
protocol in your AppDelegate
and set the listener during SDK initialization.
import UIKit
import trackier_ios_sdk
import AppTrackingTransparency
import AdServices
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, DeepLinkListener {
var window: UIWindow?
// Call for getting the deeplinking URL value
func onDeepLinking(result: DeepLink) -> Void {
print("==result: \(result.getUrlParams())")
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
/* While Initializing the Sdk, You need to pass the two arguments in the TrackierSDKConfig.
* In First argument, you need to pass the AppTrove SDK api key
* In second argument, you need to pass the environment which can be either "development", "production" or "testing". */
let config = TrackierSDKConfig(appToken: "xxxx-xx-xxx-xxx", env: TrackierSDKConfig.ENV_DEVELOPMENT) // Pass your AppTrove SDK api key
config.setDeeplinkListerner(listener: self) // Call for set deeplinking listener
TrackierSDK.initialize(config: config)
return true
}
}
Deep Link Resolver
The AppTrove iOS SDK provides a resolveDeeplinkUrl
method to resolve deferred deep links and get instant access to the deep link URL.
Using the Deep Link Resolver
import trackier_ios_sdk
// Resolve a deep link URL
TrackierSDK.resolveDeeplinkUrl(
inputUrl: "https://trackier58.u9ilnk.me/d/NKmWH9E7b1"
) { result in
switch result {
case .success(let dlData):
// Access the resolved deep link data
if let url = dlData.url {
print("Resolved URL: \(url)")
}
// Access SDK parameters
if let sdkParams = dlData.sdkParams {
print("SDK Parameters: \(sdkParams)")
}
case .failure(let error):
print("Failed to resolve deep link: \(error.localizedDescription)")
}
}
DlData Structure
public struct DlData: Codable {
public let url: String? // The resolved deep link URL
public let dlv: String? // Deep link value
public let sdkParams: [String: Any]? // SDK parameters dictionary
}
Best Practices
- Verify Universal Link Configuration: Ensure the UniLink subdomain is correctly added to the Associated Domains in Xcode and matches the Trackier Panel settings.
- Test Deep Links: Use
ENV_TESTING
orENV_DEVELOPMENT
to validate deep link behavior before deploying to production. - Handle Deep Link Data: Process the URL parameters returned by
getUrlParams()
to navigate users to the intended in-app content. - Monitor User Experience: Ensure deep links provide a seamless transition from external sources (e.g., ads, emails) to in-app content.
Troubleshooting
- Deep Links Not Working: Verify the UniLink subdomain is correctly configured in both the Trackier Panel and Xcode's Associated Domains.
- App Not Opening: Ensure the
apple-app-site-association
file is hosted correctly by Trackier and the app's entitlements include the associated domain. - URL Parameters Not Received: Confirm the
DeepLinkListener
is set during SDK initialization and theonDeepLinking
method is implemented correctly.
For further assistance, refer to the Trackier Documentation Portal or contact Trackier support at support@trackier.com.