简体   繁体   English

在 AdMob 中使用什么代替“testDevices”用于真实广告?

[英]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.我正在使用 Flutter 的firebase_admob包来显示广告,它适用于非真实广告,它们出现在应用程序上。 Also I updated adUnitId s to integrate ads to my real admob account.我还更新了adUnitId以将广告集成到我的真实 admob 帐户中。

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?那么,我应该在 testDevices 上写什么才能向真实用户展示广告而无需手动编写每个用户的设备 ID?

I found the answer with some experiments.我通过一些实验找到了答案。 I placed my app on Play Store, it works fine, it displays ads.我将我的应用放在 Play 商店中,它运行良好,显示广告。

Basically, if you want to show real ads rather than test ads let testDevices be null, do not fill it.基本上,如果你想展示真实的广告而不是测试广告,让testDevices为空,不要填充它。

And do not forget to put your real unit id from AdMob account as并且不要忘记将 AdMob 帐户中的真实单位 ID 设为

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,
  },
);
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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