Рекламный баннер не отображается - PullRequest
0 голосов
/ 03 июня 2019

Я пытался интегрировать AdMob в мою игру Unity.Я добавил пакет Google AdMob и поместил рекламный скрипт в новый игровой объект.Моя игра 3d и мое объявление не показывается.Я использовал 2 сценария, чтобы увидеть, какие из них работают, а какие нет.Я хочу это для iOS, но когда я играю в игру в Xcode, она запускается, но без рекламы.

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

public class AdsBanner : MonoBehaviour
{
    private BannerView bannerView;

    // Start is called before the first frame update
    void Start()
    {

#if UNITY_IOS
        string appId = "ca-app-pub-5414609211143331~4701275804";
#elif UNITY_IPHONE
       string appId= "ca-app-pub-5414609211143331~4701275804" ;

#else
        string appId = "" ; 
#endif

        MobileAds.Initialize(appId);
        RequestBanner();
    }

    private void RequestBanner()
    {

#if UNITY_IOS
        string bannerUnitId = "ca-app-pub-5414609211143331/4318132422";
#elif UNITY_IPHONE
       string bannerUnitId= "ca-app-pub-5414609211143331/4318132422" ;

#else
        string bannerUnitId = "" ; 
#endif
        bannerView = new BannerView(bannerUnitId, AdSize.Banner, AdPosition.Top);
        AdRequest request = new AdRequest.Builder().Build();
        bannerView.LoadAd(request);
    }
}

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

public class AdsScript : MonoBehaviour
{
    // Start is called before the first frame update
    // Use this for initialization
    void Start()
    {
        showBannerAd();
    }

    private void showBannerAd()
    {
        string adID = "ca-app-pub-5414609211143331/4318132422";

        //***For Testing in the Device***
        AdRequest request = new AdRequest.Builder()
       .AddTestDevice(AdRequest.TestDeviceSimulator)       // Simulator.
       .AddTestDevice("5414609211143331~4701275804s")  // My test device.
       .Build();

        //***For Production When Submit App***
        //AdRequest request = new AdRequest.Builder().Build();

        BannerView bannerAd = new BannerView(adID, AdSize.SmartBanner, AdPosition.Top);
        bannerAd.LoadAd(request);
    }
}

1 Ответ

0 голосов
/ 10 июня 2019

Я проверил это с вашим кодом. Моя среда разработки выглядит следующим образом:

Xcode10.2.1

Unity2018.3.11f1

В сочетании с этапами официальной документации https://developers.google.com/admob/unity/start?hl=zh-US операции приведены ниже:

1.Данный вами код должен добавить некоторый отладочный код, как показано на скриншоте. image

2.Link the AdsBanner script to the game scene, as shown in the screenshot. image

3.Then build and run, build Player Settings is as follows screenshot. image

4.In the Xcode console, look at the logs and look for the AdsBanner keyword, as shown in the screenshot. image

I have the same problem as you, the advertisement does not come out, my analysis is like this:

1.Network problems, because I am in China, I use a different network than you, I change the network (the result is still the same problem, this solution is not, not the network).

2.Admob related ID problem, I created a new app and a banner ad id with my AdMob account, the result is still the same problem, then I modify its banner ad id configuration, the problem remains, There is a setting associated with the AppStore app link in the app, I understand that its association is irrevocable, I have not tried, if you have not configured, you can try to associate.

3.In exchange for the relevant ID, I follow the https://developers.google.com/admob/unity/test-ads?hl=zh-CN рекомендации, используйте официальный рекомендуемый идентификатор теста для тестирования, показываются рекламные баннеры, указывающие на то, что интеграция кода не является проблемой.

Наконец, мой совет:

1.Проверьте настройки вашего приложения и идентификатора рекламного баннера и настройте необходимую конфигурацию, например, связь приложения AppStore, о которой я упоминал ранее.

2.Создайте новый идентификатор рекламного баннера и подождите несколько часов перед тестированием, которое может быть отложено.

3. Попробуйте разные сети, такие как сотовые сети и WI-FI.

Есть еще проблемы для совместного обсуждения, мне очень интересен этот вопрос.

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