Apple Update Token
The Apple Update Token allows you to update Apple's Ads Attribution token for enhanced tracking on iOS devices.
What is Apple Update Token?
Apple's Ads Attribution token helps maintain user attribution across app updates and reinstalls, ensuring continuous tracking and data continuity.
Library Reference
AdServices Framework
The AdServices
framework provides access to Apple's attribution token.
Documentation: Apple AdServices Framework
Requirements
- iOS 14.3 or later
- AdServices framework
- Xcode 12.0 or later
Usage
Basic Implementation
import trackier_ios_sdk
import AdServices
// Update Apple Ads token
func updateAppleAdsToken() {
if #available(iOS 14.3, *) {
let token = AAAttribution.attributionToken()
if let token = token {
TrackierSDK.updateAppleAdsToken(token: token)
}
}
}
Complete Example
import trackier_ios_sdk
import AdServices
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Get Apple Ads token before initializing SDK
updateAppleAdsToken()
// Initialize SDK
let config = TrackierSDKConfig(
appToken: "xxxx-xx-xxx-xxx", // Pass your AppTrove SDK API key
env: TrackierSDKConfig.ENV_DEVELOPMENT
)
if #available(iOS 14.3, *) {
if let token = try? AAAttribution.attributionToken() {
TrackierSDK.updateAppleAdsToken(token: token)
} else {
print("[DEBUG] Failed to fetch Apple Ads Attribution token")
}
TrackierSDK.initialize(config: config)
}
}
Function Reference
Method | Description | Parameters | Returns |
---|---|---|---|
updateAppleAdsToken(token:) | Update Apple Ads token | String | Void |
Where to Add
- App Launch: Update token when your app starts
- Token Refresh: Update when you receive a new token from your server
- Deep Link Handling: Update token before processing deep links
Best Practices
- Validate Token: Ensure token is not empty and has proper format
- Error Handling: Wrap in try-catch for network errors
- Storage: Store token securely for future use
- Availability Check: Always check iOS version before using AdServices
- Null Safety: Handle optional values properly in Swift
Support
For issues with Apple Update Token implementation, refer to our Support page.