Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Constants
- {
- static let adColonyAppID = "app0da80fed71f14b81b0"
- static let adColonyZoneID = "vzc8cf608f563b470c8f"
- static let userID = "Dy9X6wfmfoO94GtSYw2fysp4I0YGB6ji"
- }
- class ViewController: UIViewController
- {
- @IBOutlet weak var launchButton: UIButton!
- @IBOutlet weak var spinner: UIActivityIndicatorView!
- @IBOutlet weak var loadingLabel: UILabel!
- var ad: AdColonyInterstitial?
- //=============================================
- // MARK:- UIViewController Overrides
- //=============================================
- override func viewDidLoad()
- {
- super.viewDidLoad()
- let opt: AdColonyAppOptions = AdColonyAppOptions()
- opt.userID = Constants.userID
- //Configure AdColony once
- AdColony.configure(withAppID: Constants.adColonyAppID, zoneIDs: [Constants.adColonyZoneID], options: opt,
- completion:{(zones) in
- //AdColony has finished configuring, so let's request an interstitial ad
- self.requestInterstitial()
- //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
- NotificationCenter.default.addObserver(forName: .UIApplicationDidBecomeActive,
- object: nil,
- queue: OperationQueue.main,
- using: { notification in
- //If our ad has expired, request a new interstitial
- if (self.ad == nil) {
- self.requestInterstitial()
- }
- })
- }
- )
- //Show the user that we are currently loading videos
- self.setLoadingState()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement