Skip to content

ijklike/client-sdk-swift

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

client-sdk-swift

Step 1: Get the Appid

Register an account at https://console.dlink.cloud/. After creating an app on the platform, get the corresponding Appid of the app.

Step 2: Get the SDK

(1) Add Pod source in you Pod file

source 'https://github.com/CocoaPods/Specs.git'
source 'https://github.com/DLinkSDK/deeplink-dev-specs.git'

(2) add dependency

pod 'AppAttribution'

Step 3: Initialize the SDK

(1) configure and setup AttributionManager and start it

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
    let configuration = AttributionConfiguration(appId: "your_app_id")
    AttributionManager.setup(configuration: configuration, delegate: self) // setup your appid
    // start attribution manager
    AttributionManager.start()

    return true
}

(2) [!! IMPORTANT !!] Allow to make app attribution report

// 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()

(3) Implement the delegate

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)")
    }
}

(4) Directly obtain attribution results

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)")

Step 4: AppsFlyerLib Support

If your app supports AppsFlyerLib, follow the next steps

(1) Setup adapter in configuration

        var configuration = AttributionConfiguration(appId: "your_app_id")
        configuration.appsFlyerAdapter = self      // set AppsFlyerAdapter
        AttributionManager.setup(configuration: configuration, delegate: self) // set 

(2) Implements AppsFlyerAdapter Protocol

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()
    }
}

(3) Pass AppsFlyerLib conversation data to AttributionManager

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) {
        print("appsflyerlib failed \(error)")
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 95.2%
  • Ruby 4.8%