AppsFlyer 使用教程

1.工程集成

  pod 'AppsFlyerFramework'

2.初始化

private func initAppsFlyer() {
        AppsFlyerLib.shared().appleAppID = appleAppID
        AppsFlyerLib.shared().appsFlyerDevKey = appsFlyerDevKey
#if DEBUG
        AppsFlyerLib.shared().isDebug = true
#else
#endif
        AppsFlyerLib.shared().deepLinkDelegate = self
        AppsFlyerLib.shared().delegate = self
        // Only for ATT
        AppsFlyerLib.shared().waitForATTUserAuthorization(timeoutInterval: 10)
        // For Scene Delegate
        NotificationCenter.default.addObserver(self, selector: #selector(didBecomeActiveNotification),
                                               name: UIApplication.didBecomeActiveNotification,
                                               object: nil)
    }
@objc func didBecomeActiveNotification() {
    // With Listener
        AppsFlyerLib.shared().start(completionHandler: { (dictionary, error) in
          if (error != nil){
              print(error ?? "")
              return
          } else {
              print(dictionary ?? "")
              return
          }
        })
        
    }
    //  转化成功回调
    func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]) {
        if let status = conversionInfo["af_status"] as? String {
            if status == "Non-organic" {

            } else {
                print("This is an organic install.")
            }
        }
    }

    // 转化失败回调
    func onConversionDataFail(_ error: Error) {
        print("转化数据获取失败: \(error)")
    }

    // 深度链接回调
    func onAppOpenAttribution(_ attributionData: [AnyHashable : Any]) {
        print("深度链接数据: \(attributionData)")
    }

    func onAppOpenAttributionFailure(_ error: Error) {
        print("深度链接数据获取失败: \(error)")
    }
  func didResolveDeepLink(_ result: DeepLinkResult) {}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值