void ReleaseDesignerOutlets() { if (AdViewSuperView != null) { AdViewSuperView.Dispose(); AdViewSuperView = null; } if (AdViewSuperViewHeightConstaint != null) { AdViewSuperViewHeightConstaint.Dispose(); AdViewSuperViewHeightConstaint = null; } if (ContainerView != null) { ContainerView.Dispose(); ContainerView = null; } if (ContainerViewLeftMarginConstraint != null) { ContainerViewLeftMarginConstraint.Dispose(); ContainerViewLeftMarginConstraint = null; } if (ContainerViewRightMarginConstraint != null) { ContainerViewRightMarginConstraint.Dispose(); ContainerViewRightMarginConstraint = null; } if (ContainerViewTopMarginConstraint != null) { ContainerViewTopMarginConstraint.Dispose(); ContainerViewTopMarginConstraint = null; } }
} void ShowBanner(Dictionary<string, string> advertisingTargetInfo) { var bannerView = new BannerView(AdSizeCons.SmartBannerPortrait); bannerView.AdUnitID = "ca-app-pub-4252799872870196/8180596755"; bannerView.RootViewController = this; bannerView.ReceiveAdFailed += (sender, e) => { Console.Write(e.Error.LocalizedDescription); AdViewSuperViewHeightConstaint.Constant = 0; }; bannerView.AdReceived += (sender, e) => { AdViewSuperViewHeightConstaint.Constant = AddViewSuperviewHeight; }; AdViewSuperView.AddSubview(bannerView); var request = GetRequest(advertisingTargetInfo); bannerView.LoadRequest(request); } Request GetRequest(Dictionary<string, string> advertisingTargetInfo) { var request = Request.GetDefaultRequest(); request.TestDevices = new string[] { Request.SimulatorId.ToString() }; //Gender var gender = Gender.Unknown; if (advertisingTargetInfo.ContainsKey(AdKeyGender)) gender = advertisingTargetInfo[AdKeyGender].Equals("female", StringComparison.InvariantCultureIgnoreCase) ? Gender.Female : Gender.Male; request.Gender = gender; //Location var location = RealmServices.GetLastUserLocation(); if (location != null) request.SetLocation((nfloat)location.Latitude, (nfloat)location.Longitude, 1); //Birthday if (advertisingTargetInfo.ContainsKey(AdKeyBirthday)) { var birthday = DateTime.ParseExact(advertisingTargetInfo[AdKeyBirthday], "MM/dd/yyyy",null); request.SetBirthday(birthday.Month, birthday.Day, birthday.Year); } //todo Keywords return request; }