googleads-mobile-unity
googleads-mobile-unity copied to clipboard
Cannot test native ads in editor
[REQUIRED] Step 1: Describe your environment
- Unity version: 2019.4.21f1
- Google Mobile Ads Unity plugin version: 7.0.0
- Google Mobile Ads Native Unity plugin version: ??? Downloaded April 5th from google, I am not sure how to check the version
- Platform: Unity Editor
- Platform OS version: macOS Monterey 12.2.1
- Mediation ad networks used, and their versions: not mediated
[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()
);
same problem
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.