Apple Update Token
Choose your SDK version below:
- Apptrove SDK → Recommended for all projects (Latest: v2.0.0)
- Trackier SDK → Will be deprecated in May 2026 (v1.x.xx)
Use the tabs below to view Apple Update Token code for your chosen SDK.
The Apple Update Token allows you to update Apple's Ads Attribution token for enhanced tracking on iOS devices in Flutter applications.
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
flutter_asa_attribution
Flutter plugin for fetching Apple Search Ads attribution token on iOS.
Requirements:
- iOS 14.3 or later
- AdServices framework
Repository: flutter_asa_attribution
Installation
For Flutter applications, you can use the flutter_asa_attribution plugin to get the Apple Ads token.
dependencies:
flutter_asa_attribution: ^1.0.0 # Add this to your pubspec.yaml
Usage:
import 'package:flutter_asa_attribution/flutter_asa_attribution.dart';
Future<void> getToken() async {
try {
final token = await FlutterAsaAttribution.getAttributionToken();
print(token);
} catch (error) {
print(error);
}
}
Documentation:
FlutterAsaAttribution.getAttributionToken()- Fetches the attribution token from the AdServices framework on iOS. Returns a promise that resolves to the attribution token.- On Android, this method will return null.
Complete Example with SDK Initialization
- ✓ Apptrove SDK (Recommended)
- Trackier SDK (Deprecating May 2026)
import 'dart:io' show Platform;
import 'package:flutter/material.dart';
import 'package:apptrove_sdk_flutter/apptrove_sdk_flutter.dart';
import 'package:flutter_asa_attribution/flutter_asa_attribution.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void initState() {
super.initState();
initializeSDK();
}
Future<void> initializeSDK() async {
// Send token before SDK initialize (iOS)
if (Platform.isIOS) {
try {
final token = await FlutterAsaAttribution.getAttributionToken();
if (token != null && token.isNotEmpty) {
print('Apple Ads Token: $token');
AppTroveFlutterSdk.updateAppleAdsToken(token);
} else {
print('Apple Ads Token is empty or null');
}
} catch (error) {
print('Error getting Apple Ads token: $error');
}
}
final config = AppTroveSDKConfig('YOUR_APP_TOKEN', 'production');
AppTroveFlutterSdk.initializeSDK(config);
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Flutter App')),
body: Center(child: Text('Apple Ads Token Example')),
);
}
}
import 'dart:io' show Platform;
import 'package:flutter/material.dart';
import 'package:trackier_sdk_flutter/trackier_sdk_flutter.dart';
import 'package:flutter_asa_attribution/flutter_asa_attribution.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
void initState() {
super.initState();
initializeSDK();
}
Future<void> initializeSDK() async {
// Send token before SDK initialize (iOS)
if (Platform.isIOS) {
try {
final token = await FlutterAsaAttribution.getAttributionToken();
if (token != null && token.isNotEmpty) {
print('Apple Ads Token: $token');
Trackierfluttersdk.updateAppleAdsToken(token);
} else {
print('Apple Ads Token is empty or null');
}
} catch (error) {
print('Error getting Apple Ads token: $error');
}
}
final config = TrackerSDKConfig(
appToken: 'YOUR_APP_TOKEN',
environment: 'production',
);
Trackierfluttersdk.initializeSDK(config);
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Flutter App')),
body: Center(child: Text('Apple Ads Token Example')),
);
}
}
Function Reference
| Method | Description | Parameters | Returns |
|---|---|---|---|
Apptrove: AppTroveFlutterSdk.updateAppleAdsToken(token) | Update Apple Ads token | String | void |
Trackier: Trackierfluttersdk.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
- Platform Check: Only call on iOS devices
- Async Handling: Use async/await for token retrieval
- Null Safety: Handle null values properly in Dart
Support
For issues with Apple Update Token implementation, refer to the Support page, the Apptrove Documentation Portal, or contact support@apptrove.com.