Forum Cross Platform with Xamarin
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Unified native Advanced ads in xamarin.ios

Xamarinformstest21Xamarinformstest21 Member ✭✭

Hi,

I am trying to add Native Advanced (UnifiedNativeAds) in Xamarin.forms and was successful with Android but not with IOS the ads are blank. Below is my code -

protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);

        if (e.NewElement == null)
            return;

        if (e.OldElement == null)
        {
            AdSize adSize = new AdSize();
            adSize.Size = new CGSize(UIScreen.MainScreen.Bounds.Size.Width, 100);

            mAdView = new NativeExpressAdView(adSize)
            {
                AdUnitId = "ca-app-pub-xxxxxxxxxxxxx/xxxxxxxxx",
                RootViewController = UIApplication.SharedApplication.Windows[0].RootViewController
            };

            mAdView.AdReceived += (sender, args) =>
            {
                if (!viewOnScreen) this.AddSubview(mAdView);
                viewOnScreen = true;
            };


            Request request = Request.GetDefaultRequest();


            mAdView.LoadRequest(request);

           // adView.LoadRequest(Request.GetDefaultRequest());
            base.SetNativeControl(mAdView);
        }

    }

Are there are any support links that i can refer to?

For Android, I have created a layout in the Resources folder and I am binding the layout controls with ad controls. Can anyone tell me how to make something similar in IOS?

I am new to xamarin development and having a hard time to figure out this. Even detail steps that can guide me to create advance native ads will be very helpful.

Answers

Sign In or Register to comment.