2

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 Answers2

0

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

mani
  • 3,068
  • 2
  • 14
  • 25
  • i am using view to show ads and it is fixed there, how can i resize it when no ads ? – punjabidharti Aug 02 '22 at 05:03
  • You can update the NSLayoutConstraint after the ad had loaded. Set height to 0 by default, and wait for ad to load before showing. Or better ux would be to hide/set height to 0 if there is an error loading the ad – mani Aug 04 '22 at 03:03
0

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.

Seun Oboite
  • 58
  • 1
  • 7