简体   繁体   中英

What to use instead of "testDevices" in AdMob for real ADs?

I am using firebase_admob package of Flutter for displaying ads and it works on non-real ads, they appear on app. Also I updated adUnitId s to integrate ads to my real admob account.

But, when I want to display real ads I don't have any idea how to do that.

MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
  keywords: <String>['game', 'words'],
  testDevices: <String>[],
);

BannerAd myBanner = BannerAd(
  adUnitId: "[here is my unit ID]",
  size: AdSize.smartBanner,
  targetingInfo: targetingInfo,
  },
);

void initState() {
    FirebaseAdMob.instance.initialize(appId: "[my admob ID]");
    super.initState();
}

So, what should I write on testDevices in order to show ads to real users without need to write every user's device id manually?

I found the answer with some experiments. I placed my app on Play Store, it works fine, it displays ads.

Basically, if you want to show real ads rather than test ads let testDevices be null, do not fill it.

And do not forget to put your real unit id from AdMob account as

adUnitId: "your unit ID",

Final code should look like this:

...
MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
  keywords: <String>['game', 'words'],
);

BannerAd myBanner = BannerAd(
  adUnitId: "your unit ID",
  size: AdSize.smartBanner,
  targetingInfo: targetingInfo,
  },
);
...

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