‼️ The sample app was changed following Apple's announcement to postpone IDFA limitations in iOS 14
iOS 14 allows the user to prevent collection of his IDFA when the application start.
AppsFlyer's SDK - starting of version 6.0.3 - supports this functionality using Apple's AppTrackingTransperancy framework.
This sample app will allow you to test this functionality and ensure that your app is running smoothly ahead of the release of iOS 14.
-
iOS version >= 10
-
AppsFlyer SDK version 6.0.3
When the application initialises in iOS 14:
This code shows a menu that requests the user to authorise IDFA collection.
// 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
}
}
In the app you have a button 'Test IDFA collection'
The notifcations are used for the uninstall detection flow
- Clone the repository
- Make sure to open the work environment via Xcode workspace
basic_app.xcworkspace
- Get your AppsFlyer Dev Key using these instructions.
- Create the file
sdk-v6-demo/afdevkey_donotpush.plist
with the following content:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>appsFlyerDevKey</key>
<string>YOUR_AF_DEV_KEY_HERE</string>
<key>appleAppID</key>
<string>YOUR_APPLE_APP_ID_HERE</string>
</dict>
</plist>
- Add the file into your Xcode project
The file
sdk-v6-demo/sdk-v6-demo.xcodeproj/project.pbxproj
will have some changes. Do not commit them!