AdMob shows test Ads but not real Ads Swift / SwiftUI

Viewed 1026

It shows test Ads on the Simulator and on real device. But when I change the Ad ID to my real one, it is not working.. My App is also in the AppStore, but I did not push the update. I only added AdMob in Xcode and then connected my real device and tested on it. Have I to publish the new update with AdMob to the App Store to see the real ads? What should I do? I would like to test my real ads before pushing update..

(Payment details already filled)

final private class BannerVC: UIViewControllerRepresentable  {

    func makeUIViewController(context: Context) -> UIViewController {
        let view = GADBannerView(adSize: kGADAdSizeBanner)

        let viewController = UIViewController()
        view.adUnitID = bannerID
        view.rootViewController = viewController
        viewController.view.addSubview(view)
        viewController.view.frame = CGRect(origin: .zero, size: kGADAdSizeBanner.size)
        view.load(GADRequest())

        return viewController
    }

    func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}

struct Banner:View{
    var body: some View{
        HStack{
            Spacer()
            BannerVC().frame(width: 320, height: 50, alignment: .center)
            Spacer()
        }
    }
}
2 Answers

I think you do need to publish the app in order to see real ads showing up. After that it takes a while for them to show, but if you're seeing test ads, from what I remember reading, it should indicate it has been set up correctly.

After you publish, make sure you are able to select the App Store listing in the AdMob settings: AdMob > [App Name] > App Settings > App Store

If it's not showing up there, but your test ads are working fine, you might just need to wait. I had a similar situation recently and it took a full 2 (maybe 3?) weeks before real ads started showing.

Also, double-check your GADApplicationIdentifier is correct in the Info.plist file.

I had the same problem and thought I would never be able to fix it.

Reason of the error: Admob is showing test ads because the ad loaded from admob does not fit in the container, mostly a linear layout because the ad loaded is bigger in width.

Fix: How I fixed was to create a banner ad of custom size of 320x50 and then load it.

I'm unable to post my code in the answer, but you can figure out your own from Jay Patel's answer to the following stackoverflow question.

How to set adSize?

Related