ios - Finding Google DFP SDK device ID for testDevices and test ads -
i'm trying debug , develop app google's dfp sdk using google's test ad units. doing requires device's identifier (as google defines it) added request.testdevices[]
property of dfprequest object.
recent versions of dfp sdk added log message display current device's id, , added support kgadsimulatorid
running in sim. allows developer run app, copy device id console, modify code add testdevices[]
array. however, no documentation or facility exists detecting id @ run-time , consistently register current device receive test ads.
how can equivalent of google's -[gaddevice deviceidentifier]
call (this isn't public method), id can add testdevices[]
array , make app call test ads on device?
google's sdk uses prescribed [asidentifiermanager sharedmanager].advertisingidentifier
property basis identifier. creates md5 hash advertising identifier. following code allows app call test ads on device running on, if isusingtestads
flag set:
dfprequest *request = [dfprequest request]; ... if (isusingtestads) { nsstring *currentdeviceid = [self md5withstring:[[asidentifiermanager sharedmanager].advertisingidentifier uuidstring]]; request.testdevices = @[ kgadsimulatorid, // ios simulator currentdeviceid ]; ...
the md5withstring
function generic, available anywhere.
Comments
Post a Comment