Identify the test device for Admob
You should use this:
GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = ["YOUR IDENTIFIER PRINTED ON DEBUGGER"]
Instead of:
request.testDevices = ["YOUR IDENTIFIER PRINTED ON DEBUGGER"]
Swift Solution
It turns out the AdMob
/GoogleAdManager
deviceId
can be found by computing the MD5 of the advertisingIdentifier. This way you can retrieve and use the test deviceId
in code without having to previously have got a device's identifier from the console log.
To avoid the faff of using an ObjC-Swift bridging header (getting MD5 via <CommonCrypto/CommonCrypto.h>
), I'd suggest using a Swift wrapper around the CommonCrypto
framework, e.g this one:
- SwiftCrypto
Using the above framework (which adds an extension property to String
for computing the MD5 hash), it is a simple matter of querying against:
GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers ?? []).contains(ASIdentifierManager.shared().advertisingIdentifier.uuidString.md5)