I'm trying to debug and develop my app with Google's DFP SDK using Google's test ad units. Doing this requires that a device's identifier (as Google defines it) be added to the request.testDevices[]
property of a DFPRequest object.
Recent versions of the DFP SDK added a log message to display the current device's ID, and also added support for the kGADSimulatorID
for running in the sim. This allows the developer to run the app, copy the device ID from the console, then modify the code to add it to the testDevices[]
array. However, no documentation or facility exists for detecting the ID at run-time and consistently register the current device to receive test ads.
How can I get the equivalent of Google's -[GADDevice deviceIdentifier]
call (this isn't a public method), which is the ID that I can then add to the testDevices[]
array and make my app always call test ads on any device?
Google's SDK uses the prescribed
[ASIdentifierManager sharedManager].advertisingIdentifier
property as the basis for its identifier. It then creates an MD5 hash from the advertising identifier. So the following code allows my app to call test ads on any device its running on, if theisUsingTestAds
flag is set:The
md5WithString
function is generic, available from almost anywhere.