@@ -13,7 +13,7 @@ import Firebase
1313import GoogleMobileAds
1414
1515// taken from: https://developer.apple.com/documentation/uikit/view_controllers/building_a_document_browser-based_app
16- class DocumentViewController : UIViewController , DocumentDelegate {
16+ class DocumentViewController : UIViewController , DocumentDelegate , GADBannerViewDelegate {
1717
1818 private var browserTransition : DocumentBrowserTransitioningDelegate ?
1919 public var transitionController : UIDocumentBrowserTransitionController ? {
@@ -64,6 +64,7 @@ class DocumentViewController: UIViewController, DocumentDelegate {
6464
6565 document? . webview = self . webview
6666
67+ bannerView. delegate = self
6768 bannerView. adUnitID = " ca-app-pub-3940256099942544/2934735716 "
6869 bannerView. rootViewController = self
6970
@@ -84,11 +85,19 @@ class DocumentViewController: UIViewController, DocumentDelegate {
8485 bannerView. adSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth ( viewWidth)
8586 bannerView. load ( GADRequest ( ) )
8687 } else {
87- bannerView. isHidden = true
88- bannerViewHeight. constant = 0.0
88+ hideBannerView ( )
8989 }
9090 }
91+
92+ func hideBannerView( ) {
93+ bannerView. isHidden = true
94+ bannerViewHeight. constant = 0.0
95+ }
9196
97+ func adView( _ bannerView: GADBannerView , didFailToReceiveAdWithError error: GADRequestError ) {
98+ hideBannerView ( )
99+ }
100+
92101 override func viewDidAppear( _ animated: Bool ) {
93102 super. viewDidAppear ( animated)
94103 }
0 commit comments