代码之家  ›  专栏  ›  技术社区  ›  Rewind

AdMob代码使它们正确

  •  2
  • Rewind  · 技术社区  · 6 年前

    在我的Google Play Android应用程序中,我正在从测试代码转换为现实生活中的Admob代码。

    一。初始化:

    MobileAds.initialize(m_Context, myAppId);
    

    这个 myAppId 这是对的吗?

    一开始就像 "ca-app-pub-7..."

    2。横幅广告

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        app:adSize="BANNER"
        app:adUnitId="XXX"/>
    

    这个 XXX AdMob称之为横幅广告UnitId。

    一开始就像 .

    三。插页式广告

    mInterstitialAd = new InterstitialAd(m_Context);
    mInterstitialAd.setAdUnitId(adIdInterstitial);
    

    这个 adIdInterstitial 这是对的吗?

    一开始就像 “ca-app-pub-7…” .

    四。欧盟的隐私问题。

    implementation 'com.google.android.ads.consent:consent-library:1.0.6' 你需要打电话给:

    ConsentInformation consentInformation = ConsentInformation.getInstance(m_Context);
        String[] publisherIds = {adManagerNetworkCode};
        consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
        ... etc
    

    我完全不知道绳子是什么 adManagerNetworkCode 有人能告诉我这是什么吗?

    5个。我手机的测试设备Id。

    在我的代码中有一个字符串叫做 myDeviceIdForTestConsent

    mInterstitialAd.loadAd(new AdRequest.Builder()
                    .addTestDevice(myDeviceIdForTestConsent) // Todo: Remove in Release build
                    .build());
    

    我可以把这个放在里面放吗?

    这就是AdMod看到的东西吗?这样我可以继续测试我的代码,但是当我只是测试时,他们不会不公平地给我钱吗?如果是这样的话,我一定要把这个留下?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Raymond Mutyaba    6 年前
    1. 您是正确的,AppId对于测试和生产是相同的。
    2. &三。您是对的,每种类型的广告单元都有特殊的测试单元(可在AdMob文档中找到)。当您在AdMob帐户中创建这些广告单元时,可以找到生产单元。
    3. https://support.google.com/admob/answer/2784578 https://developers.google.com/admob/android/eu-consent
    4. 删除“.addTestDevice(mydeviceidfortestconcept)”。您不希望您的用户看到测试广告,或者在接收广告时遇到任何问题。