Advertisement
luck-alex13

Adcolony test

Sep 6th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 2.11 KB | None | 0 0
  1. struct Constants
  2. {
  3.     static let adColonyAppID = "app0da80fed71f14b81b0"
  4.     static let adColonyZoneID = "vzc8cf608f563b470c8f"
  5.     static let userID = "Dy9X6wfmfoO94GtSYw2fysp4I0YGB6ji"
  6. }
  7.  
  8.  
  9. class ViewController: UIViewController
  10. {
  11.     @IBOutlet weak var launchButton: UIButton!
  12.     @IBOutlet weak var spinner: UIActivityIndicatorView!
  13.     @IBOutlet weak var loadingLabel: UILabel!
  14.    
  15.     var ad: AdColonyInterstitial?
  16.    
  17.    
  18.     //=============================================
  19.     // MARK:- UIViewController Overrides
  20.     //=============================================
  21.    
  22.     override func viewDidLoad()
  23.     {
  24.         super.viewDidLoad()
  25.        
  26.         let opt: AdColonyAppOptions = AdColonyAppOptions()
  27.         opt.userID = Constants.userID
  28.        
  29.         //Configure AdColony once
  30.         AdColony.configure(withAppID: Constants.adColonyAppID, zoneIDs: [Constants.adColonyZoneID], options: opt,
  31.             completion:{(zones) in
  32.                
  33.                 //AdColony has finished configuring, so let's request an interstitial ad
  34.                 self.requestInterstitial()
  35.                
  36.                 //If the application has been inactive for a while, our ad might have expired so let's add a check for a nil ad object
  37.                 NotificationCenter.default.addObserver(forName: .UIApplicationDidBecomeActive,
  38.                                                        object: nil,
  39.                                                        queue: OperationQueue.main,
  40.                                                        using: { notification in
  41.                                                             //If our ad has expired, request a new interstitial
  42.                                                             if (self.ad == nil) {
  43.                                                                 self.requestInterstitial()
  44.                                                             }
  45.                                                         })
  46.             }
  47.         )
  48.        
  49.         //Show the user that we are currently loading videos
  50.         self.setLoadingState()
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement