marius-bughiu / Plugin.AdMob

.NET MAUI plugin for AdMob
https://startdebugging.net
MIT License
36 stars 5 forks source link

Specifying AdSize on Banner Ads throws exception on iOS #4

Closed sheyinn closed 6 months ago

sheyinn commented 6 months ago

I'm getting an error on the iOS version when I specify ad sizes. For example: <admob:BannerAd x:Name="FeedBannerAd" AdUnitId="{x:Static config:Constants.BannerAdId}" AdSize="LargeBanner" BackgroundColor="Transparent" Margin="0,10" />

This throws the error below: System.NullReferenceException: Object reference not set to an instance of an object. at Google.MobileAds.AdSizeCons.get_LargeBanner() at Plugin.AdMob.Handlers.BannerAdHandler.GetAdSize() at Plugin.AdMob.Handlers.BannerAdHandler.CreatePlatformView() at Microsoft.Maui.Handlers.ViewHandler2[[Plugin.AdMob.BannerAd, Plugin.AdMob, Version=1.0.3.0, Culture=neutral, PublicKeyToken=null]`

Removing AdSize="LargeBanner" resolves the issue.

marius-bughiu commented 6 months ago

Thank you for raising this issue. It has been fixed part of https://github.com/marius-bughiu/Plugin.AdMob/commit/cdffb939d30cd15e566755cf5b536551a4c1ad10