Advertising ID (Ad ID) is commonly used in various apps, especially in AVOD (Advertising Video On Demand) apps. Ad ID is used to show customized ads for specific customers and/or devices. Given Ad ID is used for privacy related features, it is important to provide opt-out mechanism for end users. In this KB, we will explain how to retrieve an Ad ID and opt-out status on Vega. We will also explain conditions for testing AdIdRetriever on Vega FTV devices.
Important note : AdIdRetriever is ONLY supported on the Vega FTV device . If you try to run this on the simulator, AdIdRetriever.isAdvertisingTrackingEnabled() returns false always.
Steps to integrate
- Add the following library in the
“dependencies”section topackage.json.
"dependencies": {
"@amzn/kepler-adid-retriever": "^1.0.9"
}
- Add Package ID to
manifest.toml.
[wants]
[[wants.service]]
id = "com.amazon.admanager.service.main"
- Import
AdIdRetrieverin your code.
import {AdIdRetriever} from '@amzn/kepler-adid-retriever';
- Retrieve AdID in your code.
if (AdIdRetriever.isAdvertisingTrackingEnabled()) {
const adId: string = AdIdRetriever.fetchAdvertisingId();
console.log(`Interest-based Ads is enabled. Retrieved AdID: ${adId}`);
} else {
console.log(`Interest-based Ads is disabled.`);
}
- Build and run your project. With the sample code above, you’ll see the
console.logmessages usingloggingctl(see details in Use Loggingctl to Manage System Logs | Vega CLI Tools)
Testing Conditions
- Go to Settings > Preferences > Privacy Settings > Interest-based Ads. Change it On or Off to test
AdIdRetriever.isAdvertisingTrackingEnabled() - Check the Ad ID under the Privacy Settings to test
AdIdRetriever.fetchAdvertisingId() - You can also reset Ad ID on the Ad ID setting.