Get device information
The Adtrace SDK includes helper methods that return device identifiers. Use these IDs in callbacks, server-side integrations, or internal device mapping.
| Method | Returns | Typical use |
|---|---|---|
adid | Adtrace device ID (adid) | Device mapping after install, callback placeholders, testing console |
idfa | iOS Identifier for Advertisers (IDFA) | Cross-service deduplication, callback placeholders such as {idfa} |
To set a custom external device ID before SDK init, see Set external device ID. This page covers reading adid and IDFA.
Adtrace device identifier
Method signature
+ (nullable NSString *)adid;
Adtrace generates a unique Adtrace device ID (adid) for each device. Call adid to return this ID as an NSString.
The adid is only available after Adtrace tracks the app install. You cannot read it before the SDK is initialized and the install has been successfully tracked.
Example
- Objective-C
- Swift
- Javascript
NSString *adid = [Adtrace adid];
let adid = Adtrace.adid()
let adid = Adtrace.getAdid();
ID for Advertisers (IDFA)
Method signature
+ (nullable NSString *)idfa;
The IDFA (Identifier for Advertisers) is a device-specific identifier on Apple devices. Call idfa to return this ID as an NSString.
Some analytics services need you to coordinate device and client IDs to prevent duplicate reporting. You can also pass {idfa} as a callback parameter placeholder or session callback parameter.
On iOS 14+, IDFA is only available when the user authorizes tracking. Request authorization with App Tracking Transparency before you expect a non-nil value. If the user denies tracking or has not been prompted yet, idfa may return nil.
Users can also limit ad tracking in system settings. Do not assume IDFA is always present.
Example
- Objective-C
- Swift
- Javascript
NSString *idfa = [Adtrace idfa];
let idfa = Adtrace.idfa()
Adtrace.getIdfa(function(idfa) {
console.log('IDFA = ' + idfa);
});
In WebBridge integrations, getIdfa is asynchronous and delivers the value in the callback.