How to retrieve iPhone IDFA from API?

fvisticot picture fvisticot · Oct 18, 2012 · Viewed 75.1k times · Source

I would like to get the device IDFA. How to get this info from iOS official API ?

Answer

Zachary Drake picture Zachary Drake · Oct 3, 2013

First of all:

#import <AdSupport/ASIdentifierManager.h> 

If you would like to get it as an NSString, use:

[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]

So your code might look like this:

NSString *idfaString = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];