Advertisement
RudykA

ColoringViewController

Jun 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 3.29 KB | None | 0 0
  1. class ColoringViewController: UIViewController {
  2.     private var appodealBannerHeight: CGFloat {
  3.         return Banner.height
  4.     }
  5.  
  6. override func viewDidLoad() {
  7.         super.viewDidLoad()
  8.  
  9. if !SubscriptionManager.hasSubscription() {
  10.             Appodeal.setBannerDelegate(self)
  11.             Appodeal.setInterstitialDelegate(self)
  12.            
  13.             backButtonTopConstraint?.constant = (backButtonTopConstraint?.constant)! + appodealBannerHeight
  14.             shareButtonTopConstraint?.constant = (shareButtonTopConstraint?.constant)! + appodealBannerHeight
  15.             Appodeal.showAd(AppodealShowStyle.bannerTop, rootViewController: self)
  16.         }
  17.  
  18. }
  19.  
  20. }
  21.  
  22. override func viewDidAppear(_ animated: Bool) {
  23.         super.viewDidAppear(animated)
  24.         if !SubscriptionManager.hasSubscription(),
  25.             UserDefaultsManager.shared.showInterstitialAtInput == true,
  26.             model.picture.accessStatus != .rewarded,
  27.             !rewardedShowed,
  28.             let showDate = UserDefaultsManager.shared.showInterstitialDate,
  29.             Date() > showDate.addMinutes(Double(Timeframes.timeIntervalForInterstitial / 60)){
  30.            
  31.             Appodeal.showAd(AppodealShowStyle.interstitial, rootViewController: self)
  32.         }
  33.     }
  34.  
  35. override func viewWillDisappear(_ animated: Bool) {
  36.         super.viewWillDisappear(animated)        
  37.         // Appodeal - interstitial
  38.         if !SubscriptionManager.hasSubscription(),
  39.             UserDefaultsManager.shared.showInterstitialAtOutput == true,
  40.             let showDate = UserDefaultsManager.shared.showInterstitialDate,
  41.             Date() > showDate.addMinutes(Double(Timeframes.timeIntervalForInterstitial / 60)) {
  42.            
  43.             Appodeal.showAd(AppodealShowStyle.interstitial, rootViewController: self)
  44.             UserDefaultsManager.shared.showInterstitialDate = Date()
  45.         }
  46.     }
  47.  
  48.  
  49. // MARK: - AppodealInterstitialDelegate
  50. extension ColoringViewController: AppodealInterstitialDelegate {
  51.     func interstitialDidLoadAdisPrecache(_ precache: Bool){
  52.         print("Полноэкранная реклама была загружена")
  53.     }
  54.     func interstitialDidFailToLoadAd(){
  55.         print("Полноэкранной рекламе не удалось загрузиться")
  56.     }
  57.     func interstitialWillPresent(){
  58.         print("Полноэкранная реклама сейчас будет показана")
  59.     }
  60.     func interstitialDidDismiss(){
  61.         print("Полноэкранная реклама была закрыта")
  62.         UserDefaultsManager.shared.showInterstitialDate = Date()
  63.     }
  64.     func interstitialDidClick(){
  65.         print("По полноэкранной рекламе кликнули")
  66.     }
  67. }
  68.  
  69. // MARK: - AppodealBannerDelegate
  70. extension ColoringViewController: AppodealBannerDelegate {
  71.     func bannerDidLoadAdIsPrecache(_ precache: Bool){
  72.         print("баннер был загружен")
  73.         Appodeal.showAd(AppodealShowStyle.bannerTop, rootViewController: self)
  74.     }
  75.     func bannerDidFailToLoadAd(){
  76.         print("баннеру не удалось загрузиться");
  77.     }
  78.     func bannerDidClick(){
  79.         print("баннер был кликнут")
  80.     }
  81.     func bannerDidShow(){
  82.         print("баннер был показан")
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement