private static void InitializeBannerAd() { UIWindow mainWindow = UIApplication.SharedApplication.KeyWindow; UIViewController rootViewController = mainWindow.RootViewController; UIView rootView = rootViewController.View; // Setup your GADBannerView, review GADAdSizeCons class for more Ad sizes. float bannerAdHeight = 60f; BannerAdView = new GADBannerView (size: GADAdSizeCons.SmartBannerLandscape); BannerAdView.Hidden = true; BannerAdView.AdUnitID = BannerAdUnitId; BannerAdView.Frame = new RectangleF (0, rootView.Frame.Width - bannerAdHeight, rootView.Frame.Height, bannerAdHeight + 1); BannerAdView.RootViewController = rootViewController; // Wire DidReceiveAd event to know when the Ad is ready to be displayed BannerAdView.DidReceiveAd += (object sender, EventArgs e) => { if (!BannerAdAlreadyAddedToWindow) { rootView.AddSubview (BannerAdView); BannerAdAlreadyAddedToWindow = true; } BannerAdAvailable = true; BannerAdView.Hidden = HideBannerAd; }; BannerAdView.DidFailToReceiveAd += (object sender, GADBannerViewErrorEventArgs e) => { BannerAdAvailable = false; Hide(); }; //GADRequest.Request.TestDevices = new string[] { "faa970547eb47b57b855e5ca9e3b8bc7" }; BannerAdView.LoadRequest (GADRequest.Request); }
protected override void OnElementChanged(ElementChangedEventArgs<View> e) { base.OnElementChanged(e); var adMobElement = Element as AdmobBannerView; if (null != adMobElement) { adView = new GADBannerView(GADAdSizeCons.Banner) { AdUnitID = adMobElement.AdUnitID, RootViewController = UIApplication.SharedApplication.Windows[0].RootViewController }; adView.AdReceived += (sender, args) => { if (!viewOnScreen) AddSubview(adView); viewOnScreen = true; }; adView.LoadRequest(GADRequest.Request); SetNativeControl(adView); } }
/// <summary> /// reload the view and hit up google admob /// </summary> /// <param name="e"></param> protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e) { base.OnElementChanged(e); //convert the element to the control we want var adMobElement = Element as AdMobBuddyControl; if (null != adMobElement) //TODO: does need this check here? { adView = new GADBannerView(size: GADAdSizeCons.Banner) { AdUnitID = adMobElement.AdUnitId, RootViewController = UIApplication.SharedApplication.Windows[0].RootViewController }; adView.DidReceiveAd += (sender, args) => { if (!viewOnScreen) this.AddSubview(adView); viewOnScreen = true; }; adView.LoadRequest(GADRequest.Request); base.SetNativeControl(adView); } }
public override void ViewDidLoad() { base.ViewDidLoad (); Title = AppDelegate.its.getTranslatedText ("Help"); Background back = new Background (); this.View.AddSubview (back.View); this.View.SendSubviewToBack (back.View); if (AppDelegate.Variant == "LITE") { adView = new GADBannerView (size: GADAdSizeCons.Banner, origin: new PointF (0, 66)) { AdUnitID = AppDelegate.AdmobID, RootViewController = this }; adView.DidReceiveAd += (sender, args) => { if (!viewOnScreen) View.AddSubview (adView); viewOnScreen = true; }; adView.LoadRequest (GADRequest.Request); } HelpScreenInner innerViewController = new HelpScreenInner (); UIScrollView innerScroll = new UIScrollView (View.Bounds); innerScroll.ContentSize = innerViewController.GetContentSize (); innerScroll.AddSubview (innerViewController.View); innerScroll.UserInteractionEnabled = true; View.AddSubview (innerScroll); UIBarButtonItem YouTube = new UIBarButtonItem ("YouTube", UIBarButtonItemStyle.Plain, null); YouTube.Clicked += (object sender, System.EventArgs e) => UIApplication.SharedApplication.OpenUrl (new MonoTouch.Foundation.NSUrl ("https://www.youtube.com/watch?v=aq1Ml2O8ado")); this.NavigationItem.SetRightBarButtonItem (YouTube,true); }
public static void DidReceiveAd(this IGADBannerViewDelegate This, GADBannerView view) { if (view == null) { throw new ArgumentNullException("view"); } MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr(This.Handle, Selector.GetHandle("adViewDidReceiveAd:"), view.Handle); }
public static void WillLeaveApplication(this IGADBannerViewDelegate This, GADBannerView adView) { if (adView == null) { throw new ArgumentNullException("adView"); } MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr(This.Handle, Selector.GetHandle("adViewWillLeaveApplication:"), adView.Handle); }
public static void DidActivateAd(this IGADSwipeableBannerViewDelegate This, GADBannerView banner) { if (banner == null) { throw new ArgumentNullException("banner"); } MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr(This.Handle, Selector.GetHandle("adViewDidActivateAd:"), banner.Handle); }
public static void DidFailToReceiveAd (this IGADBannerViewDelegate This, GADBannerView view, GADRequestError error) { if (view == null) throw new ArgumentNullException ("view"); if (error == null) throw new ArgumentNullException ("error"); MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr (This.Handle, Selector.GetHandle ("adView:didFailToReceiveAdWithError:"), view.Handle, error.Handle); }
public static void WillChangeAdSizeTo(this IGADAdSizeDelegate This, GADBannerView view, GADAdSize size) { if (view == null) { throw new ArgumentNullException("view"); } ApiDefinition.Messaging.void_objc_msgSend_IntPtr_GADAdSize(This.Handle, Selector.GetHandle("adView:willChangeAdSizeTo:"), view.Handle, size); }
public static void DidFailToReceiveAd(this IGADBannerViewDelegate This, GADBannerView view, GADRequestError error) { if (view == null) { throw new ArgumentNullException("view"); } if (error == null) { throw new ArgumentNullException("error"); } MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr(This.Handle, Selector.GetHandle("adView:didFailToReceiveAdWithError:"), view.Handle, error.Handle); }
public static void AdViewDidReceiveAppEvent (this IGADAppEventDelegate This, GADBannerView banner, string name, string info) { if (banner == null) throw new ArgumentNullException ("banner"); if (name == null) throw new ArgumentNullException ("name"); if (info == null) throw new ArgumentNullException ("info"); var nsname = NSString.CreateNative (name); var nsinfo = NSString.CreateNative (info); MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr_IntPtr (This.Handle, Selector.GetHandle ("adView:didReceiveAppEvent:withInfo:"), banner.Handle, nsname, nsinfo); NSString.ReleaseNative (nsname); NSString.ReleaseNative (nsinfo); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { vc = new UIViewController(); window = new UIWindow (UIScreen.MainScreen.Bounds); window.RootViewController = vc; window.MakeKeyAndVisible (); bannerView = new GADBannerView(new RectangleF(new PointF(0,vc.View.Frame.Height - GADBannerView.GAD_SIZE_320x50.Height),GADBannerView.GAD_SIZE_320x50)); bannerView.AdUnitID = "MY_BANNER_UNIT_ID"; bannerView.RootViewController = vc; vc.View.AddSubview(bannerView); bannerView.LoadRequest(new GADRequest()); return true; }
public static void AdViewDidReceiveAppEvent(this IGADAppEventDelegate This, GADBannerView banner, string name, string info) { if (banner == null) { throw new ArgumentNullException("banner"); } if (name == null) { throw new ArgumentNullException("name"); } if (info == null) { throw new ArgumentNullException("info"); } var nsname = NSString.CreateNative(name); var nsinfo = NSString.CreateNative(info); MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_IntPtr_IntPtr(This.Handle, Selector.GetHandle("adView:didReceiveAppEvent:withInfo:"), banner.Handle, nsname, nsinfo); NSString.ReleaseNative(nsname); NSString.ReleaseNative(nsinfo); }
void AddToTableView() { if (adViewTableView == null) { // Setup your GADBannerView, review GADAdSizeCons class for more Ad sizes. adViewTableView = new GADBannerView (size: GADAdSizeCons.Banner, origin: new PointF (-10, 0)) { AdUnitID = admobId, RootViewController = navController }; // Wire DidReceiveAd event to know when the Ad is ready to be displayed adViewTableView.DidReceiveAd += (object sender, EventArgs e) => { if (!adOnTable) { dvcDialog.Root.Add( new Section (caption: "Ad Section") { new UIViewElement(caption: "Ad", view: adViewTableView, transparent: true) }); adOnTable = true; } }; } adViewTableView.LoadRequest (GADRequest.Request); }
public virtual void WillChangeAdSizeTo (GADBannerView view, GADAdSize size) { throw new You_Should_Not_Call_base_In_This_Method (); }
public static void WillChangeAdSizeTo (this IGADAdSizeDelegate This, GADBannerView view, GADAdSize size) { if (view == null) throw new ArgumentNullException ("view"); ApiDefinition.Messaging.void_objc_msgSend_IntPtr_GADAdSize (This.Handle, Selector.GetHandle ("adView:willChangeAdSizeTo:"), view.Handle, size); }
public virtual void DidDeactivateAd(GADBannerView banner) { throw new You_Should_Not_Call_base_In_This_Method(); }
void InitializeAdds() { PointF origo; GADAdSize type; if (UserInterfaceIdiomIsPhone) { origo = new PointF (0, UIScreen.MainScreen.Bounds.Height); type = GADAdSizeCons.Banner; } else { origo = new PointF (0, UIScreen.MainScreen.Bounds.Height); type = GADAdSizeCons.FullBanner; } adView = new GADBannerView (size: type, origin: origo) { AdUnitID = AppDelegate.AdmobID, RootViewController = this }; adView.DidReceiveAd += (sender, args) => { if (!viewOnScreen) View.AddSubview (adView); viewOnScreen = true; }; adView.LoadRequest (GADRequest.Request); }
public static void DidReceiveAd (this IGADBannerViewDelegate This, GADBannerView view) { if (view == null) throw new ArgumentNullException ("view"); MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (This.Handle, Selector.GetHandle ("adViewDidReceiveAd:"), view.Handle); }
public virtual void AdViewDidReceiveAppEvent(GADBannerView banner, string name, string info) { throw new You_Should_Not_Call_base_In_This_Method(); }
public virtual void DidDeactivateAd (GADBannerView banner) { throw new You_Should_Not_Call_base_In_This_Method (); }
public virtual void WillPresentScreen (GADBannerView adView) { throw new You_Should_Not_Call_base_In_This_Method (); }
public virtual void WillChangeAdSizeTo(GADBannerView view, GADAdSize size) { throw new You_Should_Not_Call_base_In_This_Method(); }
void AddToWindow () { if (adViewWindow == null) { // Setup your GADBannerView, review GADAdSizeCons class for more Ad sizes. adViewWindow = new GADBannerView (size: GADAdSizeCons.Banner, origin: new CGPoint (0, window.Bounds.Size.Height - GADAdSizeCons.Banner.Size.Height)) { AdUnitID = bannerId, RootViewController = navController }; // Wire AdReceived event to know when the Ad is ready to be displayed adViewWindow.AdReceived += (object sender, EventArgs e) => { if (!adOnWindow) { navController.View.Subviews.First ().Frame = new CGRect (0, 0, 320, UIScreen.MainScreen.Bounds.Height - 50); navController.View.AddSubview (adViewWindow); adOnWindow = true; } }; } adViewWindow.LoadRequest (GADRequest.Request); }
public virtual void DidDismissScreen (GADBannerView adView) { throw new You_Should_Not_Call_base_In_This_Method (); }
public virtual void DidReceiveAd(GADBannerView view) { throw new You_Should_Not_Call_base_In_This_Method(); }
public virtual void WillLeaveApplication (GADBannerView adView) { throw new You_Should_Not_Call_base_In_This_Method (); }
public override void ViewDidLoad() { base.ViewDidLoad (); Title = AppDelegate.its.getTranslatedText ("Indexer Dashboard"); this.NavigationController.NavigationBar.Translucent = true; Background back = new Background (); Add (back.View); View.SendSubviewToBack (back.View); float mapHeight = 200; const float navbarHeight = 100; const float panelContentHeight = 1000; if (!UserInterfaceIdiomIsPhone) { mapHeight = 450; } MainMap = new OverSightMap (new RectangleF (10, navbarHeight, UIScreen.MainScreen.Bounds.Width - buffer * 2, mapHeight), this); View.AddSubview (MainMap.View); if (AppDelegate.Variant == "LITE") { adView = new GADBannerView (size: GADAdSizeCons.Banner, origin: new PointF (0, navbarHeight + mapHeight)) { AdUnitID = AppDelegate.AdmobID, RootViewController = this }; adView.DidReceiveAd += (sender, args) => { if (!viewOnScreen) View.AddSubview (adView); viewOnScreen = true; }; adView.LoadRequest (GADRequest.Request); } float statpanelwidth = UIScreen.MainScreen.Bounds.Width / 3; float rightPanelWidth = UIScreen.MainScreen.Bounds.Width - statpanelwidth - 3*buffer; const float headerheight = 100; float panelsHeight = UIScreen.MainScreen.Bounds.Height - mapHeight - buffer; const float panelY = headerheight + buffer; statpanel = new StatisticsPanel (new SizeF(statpanelwidth,panelContentHeight)); statpanelScroll = new UIScrollView (new RectangleF(buffer, mapHeight + buffer + navbarHeight, statpanelwidth, panelsHeight)); statpanelScroll.AddSubview (statpanel.View); // foreach (UIGestureRecognizer uig in statpanel.View.GestureRecognizers) { // uig.Delegate = new SwipeDelegate (); // } statpanelScroll.ContentSize = new SizeF (statpanelwidth, panelContentHeight); statpanelScroll.UserInteractionEnabled = true; View.AddSubview (statpanelScroll); rightPanelRect = new RectangleF (statpanelwidth + buffer, mapHeight + buffer + navbarHeight, rightPanelWidth, panelsHeight); rightPanel = new DashboardRightPanel (rightPanelWidth, this); // DashBoardHeader header = new DashBoardHeader (new RectangleF(0, 20 ,UIScreen.MainScreen.Bounds.Width, 22)); // View.AddSubview (header.View); AddSearchBar (); // search.AutosizesSubviews = false; // search.SizeToFit (); View.AddSubview (Search); rightPanelScroll = new UIScrollView (rightPanelRect); rightPanelScroll.ContentSize = rightPanel.getSize (); rightPanelScroll.AddSubview (rightPanel.View); rightPanelScroll.ShowsVerticalScrollIndicator = false; rightPanelScroll.UserInteractionEnabled = true; View.AddSubview (rightPanelScroll); menu = new IndexerSateliteMenu ("Dashboard", this); menu.View.UserInteractionEnabled = true; // foreach (UIGestureRecognizer uig in menu.View.GestureRecognizers) { // uig.Delegate = new SwipeDelegate (); // } View.AddSubview (menu.View); AddHelpButton (); AddSettingsButton (); curtainsIsDown = true; PullDownCurtain (); if (UserInterfaceIdiomIsPhone) { menu.SateliteButton.TouchUpInside += (object sender, EventArgs e) => ToggleCurtains (); } }
void SetUpGoogle() { try { if (iAdView != null) { iAdView.RemoveFromSuperview (); } if (googleAdView == null) { var or = this.ForOrientation (this.InterfaceOrientation); googleAdView = new GADBannerView (size: or, origin: new PointF (0, 0)) { AdUnitID = AdmobID, RootViewController = this }; googleAdView.DidReceiveAd += (object sender, EventArgs e) => { if (adView == null) return; if (adView.Superview != View) View.AddSubview (adView); adView.Hidden = false; Resize (); }; googleAdView.DidFailToReceiveAd += (object sender, GADBannerViewErrorEventArgs e) => { Console.WriteLine (e.Error); if (adView == null) return; adView.Hidden = true; ; Resize (); SetupiAd (); }; View.AddSubview (googleAdView); } adView = googleAdView; googleAdView.LoadRequest (GADRequest.Request); } catch (Exception ex) { Console.WriteLine (ex); Resize (); } }
public virtual void DidFailToReceiveAd (GADBannerView view, GADRequestError error) { throw new You_Should_Not_Call_base_In_This_Method (); }
public static void DidDeactivateAd (this IGADSwipeableBannerViewDelegate This, GADBannerView banner) { if (banner == null) throw new ArgumentNullException ("banner"); MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (This.Handle, Selector.GetHandle ("adViewDidDeactivateAd:"), banner.Handle); }
public virtual void DidReceiveAd (GADBannerView view) { throw new You_Should_Not_Call_base_In_This_Method (); }
public virtual void DidFailToReceiveAd(GADBannerView view, GADRequestError error) { throw new You_Should_Not_Call_base_In_This_Method(); }
public static void WillLeaveApplication (this IGADBannerViewDelegate This, GADBannerView adView) { if (adView == null) throw new ArgumentNullException ("adView"); MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (This.Handle, Selector.GetHandle ("adViewWillLeaveApplication:"), adView.Handle); }
void RemoveAdFromTableView () { if (adViewTableView != null) { if (adOnTable) { dvcDialog.Root.RemoveAt (idx: 2, anim: UITableViewRowAnimation.Fade); } adOnTable = false; // You need to explicitly Dispose GADBannerView when you dont need it anymore // to avoid crashes if pending request are in progress adViewTableView.Dispose (); adViewTableView = null; } }
public virtual void WillPresentScreen(GADBannerView adView) { throw new You_Should_Not_Call_base_In_This_Method(); }
void RemoveAdFromWindow () { if (adViewWindow != null) { if (adOnWindow) { navController.View.Subviews.First ().Frame = new CGRect (0, 0, 320, UIScreen.MainScreen.Bounds.Height); adViewWindow.RemoveFromSuperview (); } adOnWindow = false; // You need to explicitly Dispose GADBannerView when you dont need it anymore // to avoid crashes if pending request are in progress adViewWindow.Dispose (); adViewWindow = null; } }
public virtual void DidDismissScreen(GADBannerView adView) { throw new You_Should_Not_Call_base_In_This_Method(); }
public virtual void WillLeaveApplication(GADBannerView adView) { throw new You_Should_Not_Call_base_In_This_Method(); }
public virtual void AdViewDidReceiveAppEvent (GADBannerView banner, string name, string info) { throw new You_Should_Not_Call_base_In_This_Method (); }