带有 iOS 14 的 AppsFlyer

问题描述

我正在处理一个现有项目,之前从未使用过 AppsFlyer。

在旧版本的 AppsFlyer 中,我们使用 AppDelegate 中的这些行对其进行了初始化

    AppsFlyerTracker.shared().appsFlyerDevKey = appsflyerKey
    AppsFlyerTracker.shared().appleAppID = appId

    AppsFlyerTracker.shared().trackAppLaunch()

使用

跟踪事件
     AppsFlyerTracker.shared().trackEvent("Started",withValues: prop)

但在最新版本的 AppsFlyer 中,初始类名已从

AppsFlyerTracker -> AppsFlyerLib
// Now event is logged by
AppsFlyerLib.shared().logEvent("Started",withValues: prop)

所以我有两个问题

  1. 根据 iOS 14 中的指导方针,我们需要在任何跟踪之前添加允许用户接受它。 它是否也适用于这些 AppsFlyers logEvent 事件

  2. 如果我们需要添加权限,那么添加这些行就可以达到目的 ?

    AppsFlyerLib.shared().waitForATTUserAuthorization(timeoutInterval: 60) ATTrackingManager.requestTrackingAuthorization {(状态)在 }

  3. 我没有在最新的 AppsFlyerLib

    中找到 AppsFlyerTracker.shared().trackAppLaunch() 的替代品

解决方法

如果用户在 iOS 14 以上,则必须添加这些条件

根据您的问题:

  1. 根据 iOS 14 中的指导方针,我们需要在任何跟踪之前添加允许用户接受它。它是否也适用于这些 AppsFlyers logEvent 事件?

答案:

  1. 如果我们需要添加权限,那么添加这些行就可以达到目的吗?

答案:

最初需要添加框架 App Tracking Transparency

// The following block is optional for applications wishing to give users the option to block IDFA collection.
        // for iOS 14 and above - The user may be prompted to block IDFA collection.
        //                        If user opts-out,the IDFA will not be collected by the SDK.
        // for iOS 13 and below - The IDFA will be collected by the SDK. The user will NOT be prompted to block collection.
        if #available(iOS 14,*) {
            // Set a timeout for the SDK to wait for the IDFA collection before handling app launch
            // If timeout expires before user asks to block IDFA collection,the IDFA will be collected.
            AppsFlyerLib.shared().waitForATTUserAuthorization(timeoutInterval: 60)
            // Show the user the Apple IDFA consent dialog (AppTrackingTransparency)
            // MUST be called here before start() in order to prevent IDFA collection by the SDK
            ATTrackingManager.requestTrackingAuthorization { (status) in
            }
        }

上面的完成处理程序提示以下两点

  • 将根据用户决定授予或拒绝使用应用程序跟踪的权限来调用完成处理程序。
  • 如果对请求授权的访问受到限制,将立即调用完成处理程序。

以及你的最后一个问题

我在最新的 AppsFlyerLib 中没有找到 AppsFlyerTracker.shared().trackAppLaunch() 的替代方案

答案:

func applicationDidBecomeActive(_ application: UIApplication) {
        // Start the SDK (start the IDFA timeout set above,for iOS 14 or later)
        if #available(iOS 14,*) {
        AppsFlyerLib.shared().start()
        }else{
            AppsFlyerTracker.shared().trackAppLaunch()
        }
    }

您可以获得 AppsFlyer 团队提供的 sample project