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.