我正在做一个现有的项目,以前没有使用过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)
我有两个问题
根据iOS 14的指导方针,我们需要在任何跟踪之前添加允许用户接受的权限。是否适用于这些AppsFlyers logEvent事件
?如果我们需要添加权限,那么添加这些行将填充目的
?AppsFlyerLib.shared()。waitForATTUserAuthorization (timeoutInterval: 60)ATTrackingManager。requestTrackingAuthorization{(状态)in}
我没有找到AppsFlyerTracker.shared().trackAppLaunch()最新的AppsFlyerLib
如果用户在iOS 14以上,你必须添加这些条件
根据你的问题:
- 根据iOS 14的指导方针,我们需要在任何跟踪之前添加允许用户接受的权限。是否适用于这些AppsFlyers logEvent事件?
Ans:YES
- 如果我们需要添加权限,那么添加这些行将满足目的吗?
Ans:YES
首先你需要添加框架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团队提供的示例项目。