Register an account at https://console.dlink.cloud/. After creating an app on the platform, get the corresponding AccountId of the app.
source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/DLinkSDK/deeplink-dev-specs.git'pod 'AppAttribution'import AppAttribution
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// you can set you project-applied custom deviceid
AttributionManager.setCustomDeviceId("your device id here")
// create your configuration
// appleStoreId is your app id in the AppleStore, use format idxxx, like facebook's appleStoreId is id284882215
var configuration = AttributionConfiguration(accountId: "your_account_id", devToken: "your_dev_token", appleStoreId: "idxxxxxxx")
AttributionManager.setup(configuration: configuration, delegate: self) // setup your appid
// start attribution manager
AttributionManager.start()
return true
}// if you're ready to report app attribution, call readyToReport to start the process
// strongly recommended to begin report after you get your att auth
AttributionManager.readyToReport()- check Associated Domains is enabled in your app.
- ask DLink to get your applinks domain. add the applinks domain to your Associated Domains.
- pass the universal link info to AttributionManager in UIApplicationDelegate How to enable Universal Link
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([any UIUserActivityRestoring]?) -> Void) -> Bool {
// If you use universal link to open your app
// pass the info to AttributionManager
AttributionManager.application(application: application, continue: userActivity, restorationHandler: restorationHandler)
return true
}extension AppDelegate: AttributionManagerDelegate {
func appAttributionDidFinish(matched: Bool, info: [String : Any]) {
// app attribution finished
if matched {
print("attribution matched, get info \(info)")
// you can fetch your campaign info from here
if let campaignInfo = info[AttributionParamKey.campaignInfoKey] as? [String: Any] {
// check your campaign info params here
print("campaign info \(campaignInfo)")
}
} else {
print("attribution not matched")
}
}
func appAttributionDidFail(error: any Error) {
print("attribution failed \(error)")
}
func appAttributionDidReceiveUniversalLinkInfo(_ info: [String : Any]) {
// universal link info
print("get info from universal link \(info)")
}
}You may also obtain the attribution result by attributionInfo API. Remeber it's only available after you have finished your attribution process, or else you can only get an nil result
let info = AttributionManager.attributionInfo
print("attribution info \(info)")If your app supports AppsFlyerLib, follow the next steps
var configuration = AttributionConfiguration(appId: "your_app_id")
configuration.appsFlyerAdapter = self // set AppsFlyerAdapter
AttributionManager.setup(configuration: configuration, delegate: self) // set extension AppDelegate: AppsFlyerAdapter {
func startAppsFlyerLib() {
// Start Your AppsFlyerLib Here
AppsFlyerLib.shared().appsFlyerDevKey = "your_apps_flyer_dev_key"
AppsFlyerLib.shared().appleAppID = "your_apps_app_id"
AppsFlyerLib.shared().start()
}
func getAppsFlyerUID() -> String {
return AppsFlyerLib.shared().getAppsFlyerUID()
}
func logEvent(_ eventName: String, withValues values: [AnyHashable : Any]?) {
AppsFlyerLib.shared().logEvent(eventName, withValues: values)
}
}This step is very important!
extension AppDelegate: AppsFlyerLibDelegate {
func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]) {
// callback to AttributionManager with appsflyer result
AttributionManager.onAppflyerConversionDataSuccess(conversionInfo)
}
func onConversionDataFail(_ error: any Error) {
AttributionManager.onAppflyerConversionDataFail(error)
}
}- If you want to add GoogleAdsOnDeviceConversion support to dlink, add the podspec below
pod 'AppAttribution_GoogleAdsOnDevice'- enable the feature before setup your configuration
import AppAttribution_GoogleAdsOnDevice
AttributionManager.enableGoogleAdsOnDeviceConversion()