Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ColoringViewController: UIViewController {
- private var appodealBannerHeight: CGFloat {
- return Banner.height
- }
- override func viewDidLoad() {
- super.viewDidLoad()
- if !SubscriptionManager.hasSubscription() {
- Appodeal.setBannerDelegate(self)
- Appodeal.setInterstitialDelegate(self)
- backButtonTopConstraint?.constant = (backButtonTopConstraint?.constant)! + appodealBannerHeight
- shareButtonTopConstraint?.constant = (shareButtonTopConstraint?.constant)! + appodealBannerHeight
- Appodeal.showAd(AppodealShowStyle.bannerTop, rootViewController: self)
- }
- }
- }
- override func viewDidAppear(_ animated: Bool) {
- super.viewDidAppear(animated)
- if !SubscriptionManager.hasSubscription(),
- UserDefaultsManager.shared.showInterstitialAtInput == true,
- model.picture.accessStatus != .rewarded,
- !rewardedShowed,
- let showDate = UserDefaultsManager.shared.showInterstitialDate,
- Date() > showDate.addMinutes(Double(Timeframes.timeIntervalForInterstitial / 60)){
- Appodeal.showAd(AppodealShowStyle.interstitial, rootViewController: self)
- }
- }
- override func viewWillDisappear(_ animated: Bool) {
- super.viewWillDisappear(animated)
- // Appodeal - interstitial
- if !SubscriptionManager.hasSubscription(),
- UserDefaultsManager.shared.showInterstitialAtOutput == true,
- let showDate = UserDefaultsManager.shared.showInterstitialDate,
- Date() > showDate.addMinutes(Double(Timeframes.timeIntervalForInterstitial / 60)) {
- Appodeal.showAd(AppodealShowStyle.interstitial, rootViewController: self)
- UserDefaultsManager.shared.showInterstitialDate = Date()
- }
- }
- // MARK: - AppodealInterstitialDelegate
- extension ColoringViewController: AppodealInterstitialDelegate {
- func interstitialDidLoadAdisPrecache(_ precache: Bool){
- print("Полноэкранная реклама была загружена")
- }
- func interstitialDidFailToLoadAd(){
- print("Полноэкранной рекламе не удалось загрузиться")
- }
- func interstitialWillPresent(){
- print("Полноэкранная реклама сейчас будет показана")
- }
- func interstitialDidDismiss(){
- print("Полноэкранная реклама была закрыта")
- UserDefaultsManager.shared.showInterstitialDate = Date()
- }
- func interstitialDidClick(){
- print("По полноэкранной рекламе кликнули")
- }
- }
- // MARK: - AppodealBannerDelegate
- extension ColoringViewController: AppodealBannerDelegate {
- func bannerDidLoadAdIsPrecache(_ precache: Bool){
- print("баннер был загружен")
- Appodeal.showAd(AppodealShowStyle.bannerTop, rootViewController: self)
- }
- func bannerDidFailToLoadAd(){
- print("баннеру не удалось загрузиться");
- }
- func bannerDidClick(){
- print("баннер был кликнут")
- }
- func bannerDidShow(){
- print("баннер был показан")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement