Skip to content

Instantly share code, notes, and snippets.

@blau2
Last active June 1, 2018 21:35
Show Gist options
  • Select an option

  • Save blau2/c6a39b31e96f74df5050fbc18f9f0906 to your computer and use it in GitHub Desktop.

Select an option

Save blau2/c6a39b31e96f74df5050fbc18f9f0906 to your computer and use it in GitHub Desktop.

Revisions

  1. blau2 revised this gist Jun 1, 2018. No changes.
  2. blau2 revised this gist Jun 1, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions AppDelegate.swift
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    import AppsFlyerLib

    class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  3. blau2 created this gist Jun 1, 2018.
    29 changes: 29 additions & 0 deletions AppDelegate.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    AppsFlyerTracker.shared().appsFlyerDevKey = Keys.AppsFlyer.devKey
    AppsFlyerTracker.shared().appleAppID = Keys.Apple.appId
    AppsFlyerTracker.shared().appInviteOneLinkID = Keys.AppsFlyer.appInviteOnelinkId
    AppsFlyerTracker.shared().delegate = self
    AppsFlyerTracker.shared().isDebug = true
    return true
    }

    ...

    }

    extension AppDelegate: AppsFlyerTrackerDelegate {

    func onConversionDataReceived(_ installData: [AnyHashable: Any]!) {
    print("onConversionDataReceived")
    guard let data = installData,
    let isFirstLaunch = data["is_first_launch"] as? Int, isFirstLaunch == 1,
    let referrerReferralCode = data["referrer_af_id"] as? String else {
    return
    }
    let userDefaults = UserDefaults.standard
    userDefaults.set(referrerReferralCode, forKey: AnalyticsManager.Constants.referralCodeKey)
    }

    }