public void LoadBannerAd(UnityBannerAdPositionCodeType position, string bannerSize = UnityBannerAdSize.BANNER_SIZE_320_50) { if (!isInitialized || !adsKitSettings.GetBool(HMSAdsKitSettings.EnableBannerAd)) { return; } Debug.Log("[HMS] HMSAdsKitManager Loading Banner Ad."); var bannerAdStatusListener = new AdStatusListener(); bannerAdStatusListener.mOnAdLoaded += BannerAdStatusListener_mOnAdLoaded; bannerAdStatusListener.mOnAdClosed += BannerAdStatusListener_mOnAdClosed; bannerAdStatusListener.mOnAdImpression += BannerAdStatusListener_mOnAdImpression; bannerAdStatusListener.mOnAdClicked += BannerAdStatusListener_mOnAdClicked; bannerAdStatusListener.mOnAdOpened += BannerAdStatusListener_mOnAdOpened; bannerAdStatusListener.mOnAdFailed += BannerAdStatusListener_mOnAdFailed; bannerView = new BannerAd(bannerAdStatusListener); bannerView.AdId = adsKitSettings.GetBool(HMSAdsKitSettings.UseTestAds) ? TestBannerAdId : adsKitSettings.Get(HMSAdsKitSettings.BannerAdID); bannerView.PositionType = (int)position; bannerView.SizeType = bannerSize; bannerView.AdStatusListener = bannerAdStatusListener; _isBannerAdLoaded = false; bannerView.LoadBanner(new AdParam.Builder().Build()); if (adsKitSettings.GetBool(HMSAdsKitSettings.ShowBannerOnLoad)) { bannerView.ShowBanner(); } else { bannerView.HideBanner(); } }
public void ShowBannerAd() { if (bannerView == null) { Debug.LogError("[HMS] HMSAdsKitManager Banner Ad is Null."); return; } bannerView.ShowBanner(); }