5

This is my code:

let request = GADRequest()
request.testDevices = [kGADSimulatorID, "XXXX2F32d69CCA859FFB559D0FEA3CF6483D08A6"]
adView.load(request)

Where XXXX is my UDID of my iPhone. Why do I get real ads and not test ads on my iPhone? Test ads on the simulator works. Thank you. Tried the UDID in uppercase and lowercase.

Jens
  • 20,533
  • 11
  • 60
  • 86
J. Doe
  • 12,159
  • 9
  • 60
  • 114

3 Answers3

2

This fixed it for me!

Product -> Scheme -> Arguments -> Environment Variables if there is a key: OS_ACTIVITY_MODE, disable/remove it.

Alex Ingram
  • 434
  • 4
  • 17
  • I had the exact same situation and this worked for me, thank you! – Ten Nov 16 '22 at 02:15
  • Console when showing " GADMobileAds.sharedInstance().requestConfiguration.testDeviceIdentifiers = [ "your device" ]" just copy it to didFinishLaunchingWithOptions – Ten Nov 16 '22 at 02:31
1

As mentioned in admob guide

while running the app in device you get the below log

<Google> To get test ads on this device, call: request.testDevices = @[
@"2077ef9a63d2b398840261c8221a0c9b" ];

use that id instead of UDID.

Sandeep P
  • 94
  • 7
  • Just tried it, not working. I do not get any log message. – J. Doe Apr 09 '17 at 12:47
  • Don't set any test devices and try to run on the device, you will get the log. – Sandeep P Apr 09 '17 at 12:52
  • did you remove the last build before testing new build on real device? – OurangZeb Khan Apr 13 '17 at 09:17
  • @SandeepP yes I did not set any test devices, ran it again, no print. And I completely removed the whole app and reinstalled it, still no print, but an ad appears. – J. Doe Apr 13 '17 at 16:13
  • If you are not getting the log then try to generate the ID by referring the link http://stackoverflow.com/questions/24760150/how-to-get-a-hashed-device-id-for-testing-admob-on-ios – Sandeep P Apr 14 '17 at 13:32
1

As I understood your, I concate your UDID and ID in the log. This is wrong.

You this - pure ID :

let request = GADRequest()
        request.testDevices = [kGADSimulatorID, "2F32d69CCA859FFB559D0FEA3CF6483D08A6"]
        adView.load(request)

https://firebase.google.com/docs/admob/ios/targeting

Vyacheslav
  • 26,359
  • 19
  • 112
  • 194