void CreateAdView(NativeAdInfo ad) { CurrentAd = ad; View.Ad.Value = ad; if (ad is FailedNativeAdInfo) { View.HeadLineView.Text = ad.Headline; View.BodyView.Text = ad.Body; View.CallToActionView.Text = ad.CallToAction; } else { var nativeAd = ad.Native; nativeAd.UnregisterView(); var iconView = View.IconView?.Native(); var mediaView = View.MediaView?.Native(); var callToActionView = View.CallToActionView?.Native(); var clickables = new UIView[2] { mediaView, callToActionView }; nativeAd.RegisterView( view: this, mediaView: mediaView as ads.MediaView, iconView: iconView as ads.MediaView, UIRuntime.NativeRootScreen as UIViewController, clickableViews: clickables); } }
void CreateAdView(NativeAdInfo ad) { CurrentAd = ad; View.Ad.Value = ad; if (ad is FailedNativeAdInfo) { View.HeadLineView.Text = ad.Headline; View.BodyView.Text = ad.Body; View.CallToActionView.Text = ad.CallToAction; } else { var nativeAd = ad.Native; nativeAd.UnregisterView(); var iconView = View.IconView?.Native(); var titleView = View.HeadLineView?.Native(); var bodyView = View.BodyView?.Native(); var mediaView = View.MediaView?.Native(); var callToActionView = View.CallToActionView?.Native(); var socialContextView = View.SocialContextView?.Native(); var clickables = new List<Android.Views.View> { mediaView, callToActionView }; nativeAd.RegisterViewForInteraction( view: Container, mediaView: mediaView as ads.MediaView, clickableViews: clickables); if (iconView != null) NativeComponentTag.TagView(iconView, NativeComponentTag.AdIcon); if (titleView != null) NativeComponentTag.TagView(titleView, NativeComponentTag.AdTitle); if (bodyView != null) NativeComponentTag.TagView(bodyView, NativeComponentTag.AdBody); if (mediaView != null) NativeComponentTag.TagView(mediaView, NativeComponentTag.AdMedia); if (callToActionView != null) NativeComponentTag.TagView(callToActionView, NativeComponentTag.AdCallToAction); if (socialContextView != null) NativeComponentTag.TagView(socialContextView, NativeComponentTag.AdSocialContext); } }
public void OnNativeAdReady(NativeAdInfo ad) => NextNativeAd?.TrySetResult(ad);