简体   繁体   中英

How to run live adMob ads instead of test ads in ios Swift?

I'm close to pushing my app to the app store and before I do I would like to make sure my adMob Banner will eventually show actual ads. How do I ensure it will show live ads? Currently my code looks like this.....

bannerView.adUnitID = "ca-app-pub-***********/**************"
            bannerView.rootViewController = self
            bannerView.delegate = self

            let request = GADRequest()
            request.testDevices = [kGADSimulatorID]
            bannerView.loadRequest(request)
            bannerView.center = adCell.contentView.center
            adCell.addSubview(bannerView)

To not show test ads in the simulator, simply remove/comment out the line:

request.testDevices = [kGADSimulatorID]

This line tells AdMob to show test ads when run in the simulator (and any other device identifiers put in the array). If you were to test it on a real device right now, you would see normal ads. This line of code doesn't even need to be removed for real ads to show on a real device because you're not telling it to show test ads on any specific devices anyway (just the simulator).

Note

Clicking your own ads can get your account banned from AdMob, so be extremely careful when testing with real ads.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM