The deviceID() method tracks the IDFA (Apple's Identifier for Advertisers) that Apple automatically assigns to each device.

Syntax

#import <AdSupport/ASIdentifierManager.h>

NSString *idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
[PiwikTracker sharedInstance].deviceID = idfa;

Examples

To track the device ID (IDFA):

#import <AdSupport/ASIdentifierManager.h>

NSString *idfa = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
[PiwikTracker sharedInstance].deviceID = idfa;

Notes

  • The device ID won't be sent if isAnonymizationEnabled = YES is set.
  • If you plan to submit your app to the App Store and your app uses the device ID (IDFA) but doesn't display ads, it may be rejected during the app review process. Apple's policy allows the IDFA to be used only to serve ads.

Related methods