A Flutter plugin to access advertising ID.
Wraps ASIdentifierManager.advertisingIdentifier (on iOS) and advertising ID (on Android).
Run this command
flutter pub add advertising_id
This will add a line like this to your package's pubspec.yaml
dependencies:
....
advertising_id: ^2.7.1
Get advertising ID.
String? advertisingId;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
advertisingId = await AdvertisingId.id(true);
} on PlatformException {
advertisingId = null;
}
Retrieves whether the user has limit ad tracking enabled or not.
bool? isLimitAdTrackingEnabled;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
isLimitAdTrackingEnabled = await AdvertisingId.isLimitAdTrackingEnabled;
} on PlatformException {
isLimitAdTrackingEnabled = false;
}