question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IOS devices are always showing test ads

See original GitHub issue

I have the following ad Repository

code sample
import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:my_app/data/api/constants.dart';

class AdMobRepository {
  late String liveBannerAdId;
  late String liveInterstitualAdId;
  late String liveRewardedAdId;

  AdMobRepository() {
    if (Platform.isAndroid) {
      liveBannerAdId = Constants.androidBannedAdId;
      liveInterstitualAdId = Constants.androidInterstitualAdId;
      liveRewardedAdId = Constants.androidRewardedAdId;
    } else if (Platform.isIOS) {
      liveBannerAdId = Constants.iosBannerAdId;
      liveInterstitualAdId = Constants.iosInterstitualAdId;
      liveRewardedAdId = Constants.iosRewardedAdId;
    } else {
      liveBannerAdId = "";
      liveInterstitualAdId = "";
      liveRewardedAdId = "";
    }
  }

  BannerAd getBannerAd({
    required AdSize size,
    void Function(Ad, LoadAdError)? onFailedLoad,
    void Function(Ad)? onLoad,
    void Function(Ad)? onAdOpened,
    void Function(Ad)? onAdImpression,
  }) {
    return BannerAd(
      adUnitId: kReleaseMode ? liveBannerAdId : BannerAd.testAdUnitId,
      request: AdRequest(),
      size: size,
      listener: BannerAdListener(
        onAdFailedToLoad: onFailedLoad ?? onFailedLoadFallback,
        onAdLoaded: onLoad,
        onAdImpression: onAdImpression,
        onAdOpened: onAdOpened,
      ),
    );
  }

  void onFailedLoadFallback(Ad ad, LoadAdError error) {
    ad.dispose();
  }

  void getInterstitualAd({required void Function(LoadAdError) onFailedLoad, void Function(InterstitialAd)? onLoad}) {
    InterstitialAd.load(
      adUnitId: kReleaseMode ? liveInterstitualAdId : InterstitialAd.testAdUnitId,
      request: AdRequest(),
      adLoadCallback: InterstitialAdLoadCallback(
        onAdLoaded: onLoad ?? onInterstitialAdLoadedFallback,
        onAdFailedToLoad: onFailedLoad,
      ),
    );
  }

  void onInterstitialAdLoadedFallback(InterstitialAd ad) {
    ad.fullScreenContentCallback = FullScreenContentCallback(
        onAdDismissedFullScreenContent: (ad) => ad.dispose(), onAdFailedToShowFullScreenContent: (ad, error) => ad.dispose());
  }

  void getRewardAd({required String userId, required void Function(LoadAdError) onFailedLoad, void Function(RewardedAd)? onLoad}) {
    RewardedAd.load(
      adUnitId: kReleaseMode ? liveRewardedAdId : RewardedAd.testAdUnitId,
      request: AdRequest(),
      rewardedAdLoadCallback: RewardedAdLoadCallback(
        onAdLoaded: onLoad ?? onRewardedAdLoadedFallback,
        onAdFailedToLoad: onFailedLoad,
      ),
      serverSideVerificationOptions: ServerSideVerificationOptions(userId: userId),
    );
  }

  void onRewardedAdLoadedFallback(RewardedAd ad) {
    ad.fullScreenContentCallback = FullScreenContentCallback(
        onAdDismissedFullScreenContent: (ad) => ad.dispose(), onAdFailedToShowFullScreenContent: (ad, error) => ad.dispose());
  }
}

And I have the following widget for banner ads

    class MyBannerAd extends StatefulWidget {
    
      const MyBannerAd();
    
      @override
      _MyBannerAdState createState() => _MyBannerAdState();
    }
    
    class _MyBannerAdState extends State<MyBannerAd> {
      late AdSize adSize;
      late AdMobRepository adRepository;
      late AnalyticsRepository analyticsRepository;
      bool adLoaded = false;
      BannerAd? anchoredBanner;
    
      @override
      void initState() {
        super.initState();
        adRepository = context.read<AdMobRepository>();
        analyticsRepository = context.read<AnalyticsRepository>();
    
        if (SizerUtil.deviceType != DeviceType.mobile && SizerUtil.orientation == Orientation.portrait) {
          adSize = AdSize.leaderboard;
        } else {
          adSize = AdSize.largeBanner;
        }
    
        final bannerAd = adRepository.getBannerAd(
          size: adSize,
          onFailedLoad: (ad, error) {
            print('banner ad failed to load: $error');
            ad.dispose();
          },
          onLoad: (ad) {
            setState(() {
              adLoaded = true;
              anchoredBanner = ad as BannerAd?;
            });
          },
          onAdImpression: (_) {
            analyticsRepository.sendBannerAdShownEvent();
          },
          onAdOpened: (_) {
            analyticsRepository.sendBannerAdClickEvent();
          },
        );
    
        bannerAd.load();
      }
    
      @override
      void dispose() {
        super.dispose();
        anchoredBanner?.dispose();
      }
    
      @override
      Widget build(BuildContext context) {
        return BlocBuilder<SubscriptionBloc, SubscriptionState>(
          builder: (context, state) {
            final isLoaded = !adLoaded;
    
            if (isLoaded || state.hasSubscribed || anchoredBanner == null) return SizedBox.shrink();
    
            return Container(
              color: Colors.transparent,
              width: anchoredBanner!.size.width.toDouble(),
              height: anchoredBanner!.size.height.toDouble(),
              child: Center(
                child: Container(
                  color: Colors.white,
                  child: AdWidget(
                    ad: anchoredBanner!,
                  ),
                ),
              ),
            );
          },
        );
      }
    }

But on IOS it is always showing test ads. How can this be when the app is built with flutter release mode with flutter build ios --release? The app is currently in review and I was thinking that these ads would stop being test ads whenever it is live on the app store.

But Apple sent us the following message

We noticed that your app or its screenshots include test advertisements. Apps or metadata items that include features that are for test or demonstration purposes are not appropriate for the App Store.

Next Steps

To resolve this issue, please revise your app to complete, remove, or fully configure any partially implemented features. Please ensure your screenshots do not include any images of demo, test, or other incomplete content

So how do I get rid of the test ads? Did I miss some XCode setting or?

I am using

flutter: 2.5.3
google_mobile_ads: ^0.13.4

And I also added the GADApplicationIdentifier to my info.plist

<key>GADApplicationIdentifier</key>
<string>{here I have the app Id}</string>

And I am testing on a real device with the testflight build

Side Note:

In admob setting I have added the following test IDFA

00000000-0000-0000-0000-000000000000

which seems to work for Test ads on all IOS devices.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
duck-dev-gocommented, Dec 7, 2021

Hi, I am using this id

image

We have had those test ads for months now so real ads should be showing. We also have 30 daily active testers, so ads are shown regularly. On android everything works perfectly fine.

I will update to

google_mobile_ads: 1.0.1

But I do not think this is the cause of our problems, since we went trough multiple updates of the google mobile ads package already which did not change anything for us.

0reactions
alihassan143commented, Apr 16, 2022

For real ads to be showed in the ios devices google recommend using the tracking identifier that will allow the google to read ads identifier you can check the google ios documentation https://developers.google.com/admob/ios/ios14 I follow these steps in my flutter applications and all of my ios apps showing the ads

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling test ads | iOS - Google Developers
This guide explains how to receive test ads in your ads integration. It is important to use test ads during development so that...
Read more >
Flutter google mobile ads only shows test ads on IOS
But on IOS it is always showing test ads. How can this be when the app is built with flutter release mode with...
Read more >
Test ads not showing - Google Groups
Re test ads in the simulator and devices.not showing, in the console ... Point: iOS simulators are automatically configured as test devices.
Read more >
AdMob Ad not showing up after publish - Apple Developer
AdMob Ad not showing up after publish. Hello, I have some issues with my application. When I test my apps on emulator Ads...
Read more >
Common reasons for ads not showing - Google AdMob Help
Note: New iOS apps will not show Google ads until they're listed in the Apple App Store. Learn how to test your ads....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found