Last active
March 15, 2022 03:45
-
-
Save MichaelBarney/af66902172cb5d595795b5633522fc71 to your computer and use it in GitHub Desktop.
Revisions
-
MichaelBarney revised this gist
Oct 22, 2019 . 1 changed file with 0 additions and 33 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,33 +0,0 @@ -
MichaelBarney revised this gist
Oct 22, 2019 . 1 changed file with 33 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ import SwiftUI import GoogleMobileAds import UIKit final class Interstitial:NSObject, GADInterstitialDelegate{ var interstitial:GADInterstitial = GADInterstitial(adUnitID: interstitialID) override init() { super.init() LoadInterstitial() } func LoadInterstitial(){ let req = GADRequest() self.interstitial.load(req) self.interstitial.delegate = self } func showAd(){ if self.interstitial.isReady{ let root = UIApplication.shared.windows.first?.rootViewController self.interstitial.present(fromRootViewController: root!) } else{ print("Not Ready") } } func interstitialDidDismissScreen(_ ad: GADInterstitial) { self.interstitial = GADInterstitial(adUnitID: interstitialID) LoadInterstitial() } } -
MichaelBarney created this gist
Oct 22, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ import SwiftUI import GoogleMobileAds import UIKit final private class BannerVC: UIViewControllerRepresentable { func makeUIViewController(context: Context) -> UIViewController { let view = GADBannerView(adSize: kGADAdSizeBanner) let viewController = UIViewController() view.adUnitID = bannerID view.rootViewController = viewController viewController.view.addSubview(view) viewController.view.frame = CGRect(origin: .zero, size: kGADAdSizeBanner.size) view.load(GADRequest()) return viewController } func updateUIViewController(_ uiViewController: UIViewController, context: Context) {} } struct Banner:View{ var body: some View{ HStack{ Spacer() BannerVC().frame(width: 320, height: 50, alignment: .center) Spacer() } } } struct Banner_Previews: PreviewProvider { static var previews: some View { Banner() } }