Advertisement
Guest User

AdManager

a guest
Jan 16th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.79 KB | None | 0 0
  1. //
  2. //  AdManager.swift
  3. //  1. FC Nürnberg
  4. //
  5. //  Created by Galin Yonchev on 16.01.18.
  6. //  Copyright © 2018 Elasticbrains GmbH. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10. import EBCore
  11.  
  12. class AdManager {
  13.    
  14.     public static let sharedInstance = AdManager()
  15.    
  16.     // Setup SmartAdServer framework
  17.     public func setUp() {
  18.         SASAdView.setSiteID(101742, baseURL: "https://mobile.smartadserver.com")
  19.         #if DEBUG
  20.         SASAdView.setTestModeEnabled(true)
  21.         SASAdView.setLoggingEnabled(true)
  22.         #endif
  23.     }
  24.    
  25.     // Show SASBannerView
  26.     public func showBannerAd(withPageID pageID: String, andFormatID formatID: Int, inView bannerView: SASBannerView) {
  27.        
  28.         let rootViewController = UIApplication.shared.keyWindow?.rootViewController
  29.         guard let _ = rootViewController as? EBTabBarController else {
  30.             L_w("NOT showing banner bar: Root view controller is not a EBTabViewController")
  31.             return
  32.         }
  33.        
  34.         L_i("Showing banner ad with ID: \(pageID)")
  35.        
  36.         bannerView.loadFormatId(formatID, pageId: pageID, master: true, target: nil)
  37.        
  38.     }
  39.    
  40.     // Show SASInterstitialView
  41.     public func showInterstitial(withPageID pageID: String, andFormatID formatID: Int, inView interstitialView: SASInterstitialView) {
  42.        
  43.         let rootViewController = UIApplication.shared.keyWindow?.rootViewController
  44.         guard let _ = rootViewController as? EBTabBarController else {
  45.             L_w("NOT showing banner bar: Root view controller is not a EBTabViewController")
  46.             return
  47.         }
  48.        
  49.         L_i("Showing interstitial ad with ID: \(pageID)")
  50.        
  51.         interstitialView.loadFormatId(formatID, pageId: pageID, master: true, target: nil)
  52.     }
  53.    
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement