如何确认我的 AdMob 使用的是测试广告(不是真实广告)?

How to confirm if my AdMob is using test ads (not real ads)?

Native Ads 部分中指定:

When building and testing your apps, make sure you use test ads rather than live, production ads. Failure to do so can lead to suspension of your account.

The easiest way to load test ads is to use our dedicated test ad unit ID for Native Advanced on Android:

ca-app-pub-3940256099942544/2247696110

然而,正在显示的广告很容易被当作真实广告传递,所以我想知道是否有办法确认它们是测试广告

首先,我在初始化 MobileAds SDK 时使用我的真实 admob 应用程序 ID:

<string name="admob_app_id">ca-app-pub-xxxxxxxxxxxxxxx</string>
<string name="test_admob_app_unit_id">ca-app-pub-3940256099942544/2247696110</string>

MainActivity.kt

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        ...
        MobileAds.initialize(this, getString(R.string.admob_app_id))

然后我在AdLoader中使用上面提到的本地测试id:

MapFragment.kt

private fun showAd(){
    val adLoader = AdLoader.Builder(context, getString(R.string.test_admob_app_unit_id))
        .forUnifiedNativeAd { ad: UnifiedNativeAd ->
            /** Load image */
            val image = ad.images[0].drawable
            val options = RequestOptions.centerCropTransform()
            Glide.with(this).load(image).apply(options).into(firstImage)
            /** Load text */
            heading.text = ad.headline
            business.text = ad.advertiser
            subText.text = "Ad"
            val transaction = childFragmentManager.beginTransaction()
            transaction.show(profile)
            transaction.commit()
        }
        .build()
    adLoader.loadAd(AdRequest.Builder().build())
}

广告已成功加载,但我想要一种方法来确认它是否是测试广告,这样我的帐户就不会被暂停。

简而言之,如果您使用了 Admob 提供的正确 Ad unit ids 并且广告加载成功,您将看到一个广告,它本身表明它是一个测试广告。

The quickest way to enable testing is to use Google-provided test ad units. These ad units are not associated with your AdMob account, so there's no risk of your account generating invalid traffic when using these ad units.

因此,如果您使用提供的测试 admob id,则应该加载测试广告。

Use your own ad unit and enable test devices. You can configure your device as a test device and use your own ad unit IDs that you've created in the AdMob UI.

Quote source

如果您正在初始化测试广告,则需要使用测试单元 ID 对其进行初始化。

MobileAds.initialize(context, context.getString(R.string.admob_test_unit))

其中 R.string.admob_test_unit 是测试单元 ID。

当您看到添加时,“测试”广告被标记为“测试”(广告本身有一个小横幅)。您可以在代码中指定在 'debug' 或 'production'(发布)模式下使用哪个广告 ID,如下所示:

String intersProd_ID="<production ad unit id here";
String intersTest_ID="<test ad unit id here>";
String useInters;
    if((BuildConfig.DEBUG)){
        useInters = intersTest_ID;
    }
    else{
        useInters = intersProd_ID;
    }