Admob TestAds не отображается на устройстве - PullRequest
0 голосов
/ 24 мая 2019

Тестовые объявления Admob не будут показываться ни на одном из моих тестовых устройств, но будут регистрироваться, что они загружены в Редакторе Unity.

Я разрешил зависимости Android и покажу свой Manifest и AddCaller, у меня есть Google Repository и SDK Play Services. Я не получаю никаких ошибок, просто не покажу тестовые объявления!

манифест Android:

<?xml version="1.0" encoding="utf-8"?>
<!--
This Google Mobile Ads plugin library manifest will get merged with your
application's manifest, adding the necessary activity and permissions
required for displaying ads. android:minSdkVersion="14"
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.unity.ads"
    android:versionName="1.0"
    android:versionCode="1">

  <!-- Required -->
  <uses-permission android:name="android.permission.INTERNET"/>

  <uses-sdk android:targetSdkVersion="19" />
  <application>
  <!-- Your AdMob App ID will look similar to this sample ID:
    ca-app-pub-3940256099942544~3347511713 -->
    <meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="ca-app-pub-xxxxxxxxxx~xxxxxxx"/>
  </application>
</manifest>

AdScript:

using System.Collections;
using System;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;

public class AddScript : MonoBehaviour
{
    private string AppID = "ca-app-pub-xxxxxxxx~xxxxxxxx";

    private BannerView bannerAD;
    public InterstitialAd interAD;

    public int addTick;

    // Start is called before the first frame update
    void Start()
    {
        string appId = AppID;

        //Initialize Ads SDK
        MobileAds.Initialize(appId);
        RequestInterstitial();
        RequestBanner();
    }

    private void OnLevelWasLoaded(int level)
    {
        if (level == 2)
        {
            ShowInterstitial();
        }

        if(level == 1)
       {
            bannerAD.Show();
       }
    }

    private void RequestInterstitial()
    {
#if UNITY_ANDROID
        string adUnitId = "ca-app-pub-3940256099942544/1033173712";
#elif UNITY_IPHONE
        string adUnitId = "ca-app-pub-3940256099942544/4411468910";
#else
        string adUnitId = "unexpected_platform";
#endif

        // Initialize an InterstitialAd.
        this.interAD = new InterstitialAd(adUnitId);
        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().AddTestDevice("xxxxxxxxxxxx").Build();

        // Called when an ad request has successfully loaded.
        interAD.OnAdLoaded += HandleOnAdLoaded;
        // Called when an ad request failed to load.
        interAD.OnAdFailedToLoad += HandleOnAdFailedToLoad;

        // Load the interstitial with the request.
        this.interAD.LoadAd(request);
    }

    private void ShowInterstitial()
    {
        if (this.interAD.IsLoaded())
        {
            this.interAD.Show();
        }
        else
        {
            MonoBehaviour.print("Interstitial is not ready yet");
        }
    }


    private void RequestBanner()
    {
        string adUnitId = "ca-app-pub-3940256099942544/6300978111";

        // Create a 320x50 banner at the top of the screen.
        bannerAD = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().AddTestDevice("xxxxxxxxxxx").Build();

        // Load the banner with the request.
        bannerAD.LoadAd(request);

    }

    public void HandleOnAdLoaded(object sender, EventArgs args)
    {
        MonoBehaviour.print("HandleAdLoaded event received");
    }

    public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
    {
        MonoBehaviour.print("HandleFailedToReceiveAd event received with message: " + args.Message);
    RequestInterstitial();
    }
}

Я ожидаю, что на тестовом баннере отобразится тестовая вставка, но ничего не происходит.

и в консоли нет ошибок или предупреждений, в которых говорится, что манекен загружен и отображается правильно.

1 Ответ

1 голос
/ 24 мая 2019

месяц назад я сгенерировал свое первое приложение для публикации на андроид, и я использовал Admob, и у меня не было ошибок, я предположил, что все было правильно, после поиска в интернете я не нашел решения, реклама не показывалась, после Через 2 дня объявление появилось без изменений, в настоящее время у меня есть 3 приложения, это происходит каждый раз, когда я создаю новое приложение, подождите несколько дней.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...