Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AdMob interstitial error "Request Error: No ad to show"

Tags:

ios

swift

admob

I'm developing an iOS application using Swift2 and Xcode7. I'm trying to implement AdMob but it doesn't display my interstitial ad.

override func viewDidLoad() {
    super.viewDidLoad()

    _interstitial = createAndLoadInterstitial()
}

func createAndLoadInterstitial()->GADInterstitial {
    let interstitial = GADInterstitial(adUnitID: "interstitial_ID")
    let gadRequest:GADRequest = GADRequest()
    gadRequest.testDevices = ["test device id"]
    interstitial.delegate = self
    interstitial?.loadRequest(gadRequest)

    return interstitial!
}

func interstitialDidReceiveAd(ad: GADInterstitial!) {
    _interstitial?.presentFromRootViewController(self)
}

func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
    print(error.localizedDescription)
}

func interstitialDidDismissScreen(ad: GADInterstitial!) {
    _interstitial = createAndLoadInterstitial()
}

I receive this error:

Request Error: No ad to show.

enter image description here

like image 634
Mitsuhiko Shimomura Avatar asked Sep 28 '15 12:09

Mitsuhiko Shimomura


People also ask

How do I show interstitial ads in Android?

Interstitial ads should be displayed during natural pauses in the flow of an app. Between levels of a game is a good example, or after the user completes a task. To show an interstitial, use the isLoaded () method to verify that it's done loading, then call show () .

How do I load an ad in interstitialad?

To load an interstitial ad, call the InterstitialAd static load () method and pass in an InterstitialAdLoadCallback to receive the loaded ad or any possible errors. Notice that like other format load callbacks, InterstitialAdLoadCallback leverages LoadAdError to provide higher fidelity error details.

Should I pause the action when displaying an interstitial ad?

Remember to pause the action when displaying an interstitial ad. There are a number of different types of interstitial ads: text, image, video, and more. It's important to make sure that when your app displays an interstitial ad, it also suspends its use of some resources to allow the ad to take advantage of them.


2 Answers

Request Error: No ad to show.

means that your request was successful but that Admob has no ad to show for your device at this time. The best way to ensure that you always have ads to show is to use mediation so that an unfulfilled request falls through to another ad network. Admob provides good mechanisms to do that.

like image 61
William Avatar answered Oct 18 '22 19:10

William


You should have two Ad Unit ID's. One for your GADBannerView and one for your GADInterstitial. Make sure your Ad Unit ID supplied by AdMob for your interstitial is exactly the same as what they've given you. Update to the latest AdMob SDK, currently 7.5.0. Also consider calling presentFromRootViewController(self) at specific intervals or once the user completes a desired action. The way you have it setup now will keep presenting interstitials one after another because you are sending requests for new interstitials every time one is dismissed and then displaying the interstitial as soon as it receives an ad.

import UIKit
import GoogleMobileAds

class ViewController: UIViewController, GADInterstitialDelegate {

    var myInterstitial : GADInterstitial?

    override func viewDidLoad() {
        super.viewDidLoad()
        myInterstitial = createAndLoadInterstitial()
    }

    func createAndLoadInterstitial()->GADInterstitial {
        let interstitial = GADInterstitial(adUnitID: "Your Ad Unit ID")
        interstitial.delegate = self
        interstitial?.loadRequest(GADRequest())
        return interstitial
    }

    @IBAction func someButton(sender: AnyObject) {
        myInterstitial?.presentFromRootViewController(self)
    }

    func interstitialDidReceiveAd(ad: GADInterstitial!) {
        print("interstitialDidReceiveAd")
    }

    func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
        print(error.localizedDescription)
    }

    func interstitialDidDismissScreen(ad: GADInterstitial!) {
        print("interstitialDidDismissScreen")
        myInterstitial = createAndLoadInterstitial()
    }
like image 32
Daniel Storm Avatar answered Oct 18 '22 18:10

Daniel Storm