I'm working on an existing project and haven't used AppsFlyer before.
in older version of AppsFlyer we have initialized it using these lines in AppDelegate
AppsFlyerTracker.shared().appsFlyerDevKey = appsflyerKey
AppsFlyerTracker.shared().appleAppID = appId
AppsFlyerTracker.shared().trackAppLaunch()
And Track events using
AppsFlyerTracker.shared().trackEvent("Started", withValues: prop)
But in the latest version of AppsFlyer the initial class name has changed from
AppsFlyerTracker -> AppsFlyerLib
// now event is logged by
AppsFlyerLib.shared().logEvent("Started", withValues: prop)
So I have two questions
As according to guide lines in iOS 14, we need to add permission for user to accept it before any tracking. Is it applies to these AppsFlyers logEvent event too ?
if we need to add permission then adding these lines will fill the purpose ?
AppsFlyerLib.shared().waitForATTUserAuthorization(timeoutInterval: 60) ATTrackingManager.requestTrackingAuthorization { (status) in }
I didn't find alternate for AppsFlyerTracker.shared().trackAppLaunch() in the latest AppsFlyerLib
if user in above iOS 14 you must need to add these condition
based on your question :
- As according to guide lines in iOS 14, we need to add permission for user to accept it before any tracking. Is it applies to these AppsFlyers logEvent event too ?
Ans : YES
- if we need to add permission then adding these lines will fill the purpose ?
Ans : YES
initially you need to add the framework 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
}
}
the above completion handler prompts the following two points
and your final question
I didn't find alternate for AppsFlyerTracker.shared().trackAppLaunch() in the latest AppsFlyerLib
Ans :
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()
}
}
you can get the sample project provided by AppsFlyer's team.