Adding Google AdMob to Xamarin Forms iOS
There are already several good implementation guides to get Google Admob into your Xamarin Forms application, depending on what you need, e.g. from James Montemagno, Adam Pedley, Sharma Pranav or many others. Everything went fine on the first day on the simulator, using Googles Test Ad Unit IDs. But on the second day, Ads are not displayed anymore…
When running on iPhone Simulator, I got messages like the following in my Application Output:
<Google> To get test ads on this device, call: request.testDevices = @[ kGADSimulatorID ];
<Google> Cannot find an ad network adapter with the name(s): com.google.DummyAdapter. Remember to link all required ad network adapters and SDKs, and set -ObjC in the ‘Other Linker Flags’ setting of your build target.
Surprisingly, why do I need to register devices if I use Googles Test IDs? Why don’t they just deliver the test ads to all devices? Anyway, James Montemagno has the answer here: In the AdBanner iOS Renderer, add the Testdevices to your request:
Request GetRequest() { var request = Request.GetDefaultRequest(); request.TestDevices = new [] { Request.SimulatorId.ToString () }; return request; }
This is the code for the simulator, and fortunately Google prints the deviceID to your Application Output if you run it on an iOS Device.
So this fixed the first error (“To get test ads on this device, call: request.testDevices…”) but the second error still appears in my app.
I tried several advices, e.g. resetting Advertising Identifier in Settings -> Privacy -> Advertising, but could not get it to work anymore 🙁
I ended up using my live Ad Unit ID instead of Googles Test IDs. As long as I’m on the simulator it still says “Test Ad” so it’s fine to use the live Ad Unit ID on the simulator without generating paid clicks (and maybe get banned on Admob).