It's great that your test ads are working, as that indicates your AdMob SDK implementation is generally correct. Getting a Code=1 error for live ads (often accompanied by "Request Error: No ad to show") is very common when transitioning from test to production.
Here's a breakdown of what you need to do and why you're likely seeing that error:
Understanding AdMob Error Code 1 ("Request Error: No ad to show.")
This error typically means that AdMob couldn't find an ad to return for your request. While it
can sometimes indicate an invalid Ad Unit ID or App ID, given that your test ads work, the problem almost always lies with the "readiness" of your app or AdMob account to serve live ads.
Key Steps to Get Live Ads Working:
- Ensure You're Using Your Live Ad Unit IDs:
- Double-check that you've replaced the test Ad Unit IDs (e.g., ca-app-pub-3940256099942544/2934735716 for banner) with the actual Ad Unit IDs you generated in your AdMob account for your specific app.
- Similarly, ensure your AdMob App ID in your Info.plist (the GADApplicationIdentifier) is your live App ID, not a test one.
- Remove Test Device Identifiers from Your Code:
- When you were debugging, you likely added your device's ID to GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers.
- Crucially, you must remove this code before building for production. If it's still there, AdMob will continue to serve test ads to that device, even with your live IDs.
- App Approval and Linking in AdMob:
- Your app must be published on the App Store (or another supported app store) for AdMob to fully review and approve it for serving live ads. This is the most common reason for Code=1 when test ads work.
- Link your app to the App Store in your AdMob account:
- Sign in to your AdMob account.
- Go to Apps in the sidebar.
- Click View all apps.
- Find your app and ensure it's linked to its App Store listing. If it's not, you'll need to add the App Store URL.
- Once linked, AdMob will automatically begin reviewing your app. You can check its "Approval status" in AdMob (it might show "Getting ready" or "Requires review").
- Patience is key: The review process can take a few days, or sometimes longer. Ads will only start serving once your app is approved.
- AdMob Account Setup & Verification:
- Complete your AdMob account setup entirely. This includes:
- Billing information: Ensure your payment details are correctly set up.
- PIN verification: If you're a new publisher, AdMob will send a PIN to your address once you reach a certain earnings threshold. Your account won't be fully verified for payments until this is done, and this can sometimes impact ad serving.
- Policy Center: Check your AdMob Policy Center for any violations or issues. Any policy violations will prevent ads from serving.
- Seller Information: Ensure your seller information is set to "Transparent" in your AdMob settings.
- app-ads.txt File (Highly Recommended):
- While not always a direct cause of Code=1, setting up an app-ads.txt file is crucial for maximizing your ad revenue and preventing unauthorized inventory sales.
- AdMob provides instructions on how to create and host this file on your developer website. It helps advertisers verify that you are the legitimate seller of your ad inventory.
- Network Fill Rate:
- Sometimes, especially for new apps or in certain regions, AdMob might simply not have an ad to fill every request. This results in a Code=1 (No ad to show). As your app gains users and requests increase, this often resolves itself.
Debugging Checklist for Code=1:
- Are you using production Ad Unit IDs and App ID? (Yes, confirmed in your question)
- Have you removed all testDeviceIdentifiers code?
- Is your app published on the App Store?
- Is your app linked to its App Store listing in AdMob?
- What is the "Approval status" of your app in AdMob? Is it "Ready" or still "Getting ready"?
- Is your AdMob account fully set up and verified (billing, PIN, no policy violations)?
- (Optional but recommended) Have you set up your app-ads.txt file?
If you've done all of the above, and your app's status in AdMob is "Ready," but you still get Code=1, then it might be a fill rate issue or something more specific to your account that AdMob support can help with. They often ask for your App ID and Ad Unit IDs to investigate further.