Skip to content

Instantly share code, notes, and snippets.

@oxlb
Created February 20, 2020 08:57
Show Gist options
  • Select an option

  • Save oxlb/a4fa9a111ab7b060cafd3f531324e77a to your computer and use it in GitHub Desktop.

Select an option

Save oxlb/a4fa9a111ab7b060cafd3f531324e77a to your computer and use it in GitHub Desktop.
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, AppsFlyerTrackerDelegate{
// ...
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
AppsFlyerTracker.shared().appsFlyerDevKey = "repLaceWithYourDevKeY"
AppsFlyerTracker.shared().appleAppID = "123456789"
// ...
AppsFlyerTracker.shared().delegate = self
}
func onConversionDataSuccess(_ installData: [AnyHashable: Any]) {
//Handle Conversion Data (Deferred Deep Link)
}
func onConversionDataFail(_ error: Error?) {
// print("\(error)")
}
func onAppOpenAttribution(_ attributionData: [AnyHashable: Any]) {
//Handle Deep Link Data
}
func onAppOpenAttributionFailure(_ error: Error?) {
}
// Reports app open from a Universal Link for iOS 9 or later
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
AppsFlyerTracker.shared().continue(userActivity, restorationHandler: restorationHandler)
return true
}
// Reports app open from deep link from apps which do not support Universal Links (Twitter) and for iOS8 and below
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
AppsFlyerTracker.shared().handleOpen(url, sourceApplication: sourceApplication, withAnnotation: annotation)
return true
}
// Reports app open from deep link for iOS 10 or later
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
AppsFlyerTracker.shared().handleOpen(url, options: options)
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment