iosadmob

Admob - InterstitialAd.load error code 21


I'm getting the following error when trying to load an interstitial ad through admob in my iOS app. I'm thinking I have something configured wrong, but I'm not really sure what the error message means in order to debug any further. Can someone PLEASE tell me what this means?

Error Domain=com.google.admob Code=21 "The ad string could not be loaded because it was invalid." UserInfo={NSLocalizedDescription=The ad string could not be loaded because it was invalid.}

Failing code:

let adUnitID = "ca-app-pub-3940256099942544/4411468910" // admit test interstitial ad unit id
interstitial = try await InterstitialAd.load(with: adUnitID)

Thanks in advance!


Solution

  • It seems like you're missing a Request() within .load method, as mentioned here.

    let adUnitID = "ca-app-pub-3940256099942544/4411468910"
    interstitial = try await InterstitialAd.load(with: adUnitID, request: Request()) // 👈