Skip to content

Instantly share code, notes, and snippets.

@ydn
Last active August 29, 2015 14:22
Show Gist options
  • Save ydn/481331cb095fa767ecd2 to your computer and use it in GitHub Desktop.
Save ydn/481331cb095fa767ecd2 to your computer and use it in GitHub Desktop.
Full-Screen Ads (complete example) with Swift
class ViewController: UIViewController, FlurryAdInterstitialDelegate {
let adInterstitial = FlurryAdInterstitial(space:"ADSPACE");
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated);
adInterstitial.adDelegate = self;
adInterstitial.fetchAd();
}
override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated);
}
/**
* Invoke an interstitials at a natural pause in your app. For example, when a
* level is completed, an article is read or a button is pressed. Here we
* mock the display of ant interstitials when a button is pressed.
*/
@IBAction func showFullScreenAdClickedButton(sender: AnyObject) {
if adInterstitial.ready {
adInterstitial.presentWithViewController(self);
} else {
adInterstitial.fetchAd();
}
}
}
@dbgrandi
Copy link

If you make the let adInterstitial a lazy property, users can inject a mock during testing. Good practice, but may complicate the example.

@dbgrandi
Copy link

There should be no reason to test if adInterstitial != nil in the bottom method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment