googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.36k stars 1.08k forks source link

Cannot test native ads in editor #2013

Closed pfay-fc closed 1 year ago

pfay-fc commented 2 years ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

After making the call to load a native ad in editor, none of the events are fired (i.e. OnCustomNativeAdLoaded, OnNativeAdLoaded, or OnAdFailedToLoad), despite having added listeners.

From what I can see, test native ads in editor are not supported. Interstitials work fine, and I can see test interstitials in client. I haven't tested RVs and banners, but they are supported (and I believe even app open is supported). Also note that I have been able to load a test native ad on an android device, and log out the text (although I didn't render it).

For non-native ad types, they have special for-editor clients constructed through the GoogleMobileAdsClientFactory. However for native, the GoogleMobileAdsNativeClientFactory will only construct a DummyNativeClient in editor which simply logs requests and does nothing.

If I am incorrect and this is supported, please let me know where I am going wrong. Also if the native plugin is not under the purview of this github repo, please let me know where I should request this feature.

Compared to the relative simplicity of showing an interstitial, rendering the different formats of a native ad in unity seems more involved. Are people implementing native ads without testing in editor, or perhaps using their own test logic? It seems like a very important thing to support to encourage developers to use native ads.

Relevant Code:

// after initializing sdk completed
string adUnitId = "ca-app-pub-3940256099942544/2247696110"; // android test ad slot for native, for interstitials this isn't used, "unused" works fine
AdLoader adLoader = new AdLoader.Builder(adUnitId)
                .ForNativeAd()
                .Build();

// I have these functions all defined, none are ever called
adLoader.OnCustomNativeAdLoaded += this.HandleCustomNativeAdLoaded;
 // I would expect one of the two below to be called
adLoader.OnNativeAdLoaded += this.HandleNativeAdLoaded;
adLoader.OnAdFailedToLoad += this.HandleNativeAdFailedToLoad;

adLoader.LoadAd(new AdRequest.Builder()
                //.AddExtra("ft_ctype", "text_app_install") // would be nice to test different creative types here, as per https://developers.google.com/ad-manager/mobile-ads-sdk/android/test-creative-types
                .Build()
            );
mana-break commented 2 years ago

same problem

NVentimiglia commented 1 year ago

Thanks for the feedback,

I will make the feature request that we need a extensibility point so that we can test native ads from the editor.