skip to Main Content

I am trying to implement ads in my app, code and app running perfectly, but ads not.
I am getting an error in console

<Google> Invalid Request. Invalid ad width or height: (0, 0)
bannerView:didFailToReceiveAdWithError: Invalid ad width or height: (0, 0)

Even if I Add frame width and height. Here is my simple code for test:

            HStack {
                Spacer()
                BannerAd(unitID:
                            "ca-app-pub ...")
                .frame(width: 320, height: 50)
            }

I tried adding frame, changing width and height but still getting this error.

2

Answers


  1. Chosen as BEST ANSWER

    I found a solution by myself. I just had BannerAd without anything. If anyone are struggling with this try to do that under the text:

    VStack { 
      Text("") 
      BannerAd(unitID:"ca-app-pub ...")
    }
    

  2. I had my BannerAd(unitID:"ca-app-pub …") inside a ScrollView. When I moved it to a ZStack, it worked.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search