Home > front end >  AdMob: Invalid frame size
AdMob: Invalid frame size

Time:11-08

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.

CodePudding user response:

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 ...")
}
  • Related