LynxTracking
Asks whether your app may track the person across other companies' apps and websites, and says what they answered. An ad or install-attribution SDK then reads the advertising ID only once they've allowed it. import { LynxTracking } from '@blotch/angular-lynx';
Turn it on
Add tracking to permissions in the build target's options in angular.json, with the reason iOS shows when it asks:
What it adds:
- iOS:
NSUserTrackingUsageDescriptionin Info.plist, and the native code behind App Tracking Transparency's prompt. It doesn't declare tracking in the app's privacy manifest (PrivacyInfo.xcprivacy): Apple requiresNSPrivacyTrackingto come with the domains the app tracks with, which the build doesn't know. If your app connects to tracking domains, eject the iOS project and add both keys toios/App/PrivacyInfo.xcprivacy. From iOS 17, requests to a listed domain fail until the person allows tracking. - Android: the
com.google.android.gms.permission.AD_IDpermission in the manifest, the native code, and Google Play services' advertising ID library.
Without it, the native code is left out of both apps, and the advertising ID library out of the Android one. That's because iOS ends an app that shows the prompt without a reason. Nothing rejects: status() becomes unsupported, and requestPermission() resolves with it.
See Turn on device features for every setting.
Usage
Ads stands for the app's own wrapper around its ad SDK.
Ask when the person can see why, such as when they first open a screen with ads, rather than as the app launches.
- iOS shows the prompt only once per install, and only to an app in the foreground.
- A request made while the app isn't active waits until it is.
What the stores require
Both stores require this of an app that tracks:
- iOS: since iOS 14.5, the advertising ID reads as zeros until the person allows tracking in App Tracking Transparency's prompt. App Review rejects an app that tracks without asking (guideline 5.1.2).
- Android: Google Play gives an app that targets Android 13 or later the advertising ID only when it declares the
AD_IDpermission. There's no prompt, but the person can opt out of personalized ads, or delete the ID, in Settings. Play's policy says to respect it.
API
LynxTracking
status
Whether the app may track the person, as a signal. It's read when the service is created, and again each time the app comes back to the foreground, since the person can change it in Settings meanwhile. Until the first answer, a moment after the service is created, it's notDetermined.
requestPermission()
Shows App Tracking Transparency's prompt on iOS, if the person hasn't been asked yet, and resolves with their answer, which status then holds too. Anywhere else, and once the person has answered, it resolves with the status without showing anything. It never rejects.
TrackingStatus
LynxTracking doesn't read the advertising ID itself: the ad or attribution SDK does, once the status is authorized.
Testing
Each test starts where a fresh install on an iPhone does, notDetermined, and the prompt allows tracking. setTrackingStatus() sets the status, setTrackingAnswer() what the prompt answers, and trackingPrompts() counts the prompts shown:
Related
- Turn on device features:
permissions.trackingand the other opt-in settings
