skip to Main Content

I want to implement AdMob ads in my ios app, all works fine but the problem is my app is fully work without internet also, so when ads show there is no problem but when ads are not showing only blank screen appears which is not good for app,, look at these images below…

this is image with ad

now look at this picture without ad and only blank space

i want to remove this blank space , is it possible to move bells and image up when no ads display,, thanks

2

Answers


  1. For iOS SDK have a look at https://developers.google.com/admob/ios/banner#implementing_banner_events

    And wait for bannerViewDidReceiveAd before displaying your ad.

    If using react native have a look at this answer for an implementation:
    https://stackoverflow.com/a/54566364/2303348

    Login or Signup to reply.
  2. Ad: Monitor your Admob earnings using the Motics ios app.

    I’ll be guessing your banner ad is embedded in a view. To remove the blank space when there’s no ad to show (e.g due to issues such as no internet).

    • Check there’s no ad to show.
    • Remove/hide the view. This assumes you are using appropriate constraints.

    Sample code below:

    import GoogleMobileAds // Google Ads
    import UIKit
    import VHMessengerKit // Chat sdk
    
    class ViewController: UIViewController, GADBannerViewDelegate {
    
      var bannerView: GADBannerView!
      var yourView: UIView! // This can be your outlet.
    
      override func viewDidLoad() {
        super.viewDidLoad()
    
        bannerView.delegate = self
        yourView.addSubView(self.bannerView)
      }
    
      func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) {
      // No ad received or nothing to show.
      self.changeViewItem()
     }
    
     func changeViewItem(){
         self.yourView.frame.size.height = 0
         self.yourView.hidden = true
      }
    }
    
    

    If you are not embedding your ad in a view, replace the banner ad directly.

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