marcojak / MauiMTAdmob

MIT License
104 stars 17 forks source link

Banner Ads space on screen not automatically hiding/removing when ad doesn't show/load in .Net MAUI Blazor iOS #70

Open bangaras opened 3 months ago

bangaras commented 3 months ago

I am working on .Net MAUI Blazor iOS, I have added bottom space for showing banner ads, but when ads doesn't show/load then my bottom space still present. In Android it automatically handles when ad doesn't load. Same code I have in .Net Blazor iOS. Please give me any suggestion how can I remove when ads doesn't load.

//MainPage.cs code

public partial class MainPage : ContentPage
{
    Grid grid;
    public MainPage()
    {
        InitializeComponent();
        if (DeviceInfo.Current.Platform == DevicePlatform.Android || DeviceInfo.Current.Platform == DevicePlatform.iOS)
        {
            grid = new Grid()
            {
                RowDefinitions =
                {
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }
                }
            }
        }
        else
        {
            grid = new Grid()
            {
                RowDefinitions =
                {
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(0) }
                }
            };
        }
        BlazorWebView blazorWebView = new BlazorWebView() { HostPage = "wwwroot/index.html" };
        blazorWebView.RootComponents.Add(new RootComponent() { Selector = "#app", ComponentType = typeof(Main) });
        grid.Add(blazorWebView, 0, 0);
        MTAdView myAds = new MTAdView();
        if (DeviceInfo.Current.Platform == DevicePlatform.Android || DeviceInfo.Current.Platform == DevicePlatform.iOS)
        {
            grid.Add(myAds, 0, 1);
        }
        contentpg.Content = grid;
#if __ANDROID__
        myAds.AdsId = "xyz";
#elif __IOS__
        myAds.AdsId = "xyz";
#endif
    }