Open alexberardi opened 4 months ago
Hi @alexberardi, it's a bug, thank you for reporting it.
You can work around it by setting AdConfig.DefaultInterstitialAdUnitId
to match your ad unit id.
That worked! Thank you!
Do you have any information on the test device situation? I'm able to see ads in the iOS simulator, Android simulator, and a physical Android device but not an iOS device.
I would need to look into it, unfortunately I don't have an iOS device to test with, only the simulator. From what I figure, the test device IDs are set correctly - https://github.com/marius-bughiu/Plugin.AdMob/blob/887bfeecc801b77bccd93c2cc085bf2defa4201e/src/Plugin.AdMob/Platforms/iOS/InterstitialAdService.cs#L26
A wild guess would be that maybe that test devide IDs need to be set before Request.GetDefaultRequest()
? I'll try to have a look at it this weekend and see if I can figure it out, but I can't make any promises.
In the meantime you could try:
PrepareAd
twice, the second call would be guaranteed to have the test device IDs set if that's the issueAdConfig
- you could try setting MobileAds.SharedInstance.RequestConfiguration.TestDeviceIdentifiers
from your code (this is platform-specific code, so it would need to go into your Platforms/iOS
folder.alexberardi, have you managed to get this working? If not, I'm going to mark this with help wanted
until I get my hands on an iOS device so I can troubleshoot; maybe someone else finds some spare time to do it.
I have not been able to get it working on a physical device, but I'm not sure if that's because my app is not published yet or if there's an underlying issue.
@marius-bughiu My app is now published and I can confirm the ads are not working on iOS. I'm able to see the requests come through on AdMob but nothing shows on the device.
@alexberardi, I've got my hands on an iPhone XR running iOS 17.4.1 and at least the test ads are showing - these are photos running the sample app in the repo:
1 | 2 | 3 |
---|---|---|
Could it be something related to the iOS version of the device or some privacy settings?
@marius-bughiu - finally was able to get ads working on iOS. The issue is that you need to set the DefaultBannerAdUnitId for production ads to work. I set the value and now I'm getting ads. Thank you! Leaving open because I'm not sure if you'd like to fix that but feel free to close if you are too busy.
Hello, I am trying to get Interstitial ads working in my .NET Maui application. It is currently failing on both iOS and Android.
In my view model, I am retrieving the singleton IInterstitialAdService from Service provider and running: _interstitialAdService.PrepareAd("{MY_AD_UNIT_ID}");
Then, on button click I am running: _interstitialAdService.ShowAd();
On that method call, my app crashes with an error: System.ArgumentNullException: Value cannot be null. (Parameter 'adUnitId') at ObjCRuntime.ThrowHelper.ThrowArgumentNullException(String argumentName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/ThrowHelper.cs:line 28 at Google.MobileAds.InterstitialAd.Load(String adUnitId, Request request, InterstitialAdLoadCompletionHandler completionHandler) at Plugin.AdMob.Services.InterstitialAdService.PrepareAd(String adUnitId) at Plugin.AdMob.Services.InterstitialAdService.ShowAd()
When I inspect _insterstitialAdService, I can see the private property "_ad" is indeed populated and it's AdUnitId property is populated with my ad unit id.
I've also tested using the test unit id's here: https://developers.google.com/admob/ios/test-ads#demo_ad_units with the same result.
Am I doing something wrong or is this a bug?
Additionally, it doesn't seem like AddTestDevice is working. When I run the application on my simulator, I am able to see a Test Ad banner. However, when I try running on my device, I am not able to see the banner.
In my MauiProgram.cs, I am executing: AdConfig.AddTestDevice("{MY_TEST_DEVICE_AD_ID}");
This device has been added to AdMob as a test device with a matching Ad ID.
In the console, I see a message: