Created
September 25, 2014 18:36
-
-
Save flurrydev/fe7d719c75e0c7a5203d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "FlurryAdDelegate.h" | |
#import "FlurryAds.h" | |
/** | |
* You can integrate interstitials in any placement in your app, but for | |
* testing purposes we present integration within your ViewController | |
*/ | |
// the adSpaceName refers to the ad space configured on dev.flurry.com under Publishers tab | |
// under left-hand nav Inventory / Ad Spaces | |
NSString *adSpaceName = @”INTERSTITIAL_MAIN_VIEW”; | |
- (void)viewDidAppear:(BOOL)animated { | |
[super viewDidAppear:animated]; | |
// Register yourself as a delegate for ad callbacks | |
[FlurryAds setAdDelegate:self]; | |
// Fetch fullscreen ads early when a later display is likely. For | |
// example, at the beginning of a level. | |
[FlurryAds fetchAdForSpace:adSpaceName frame:self.view.frame size:FULLSCREEN]; | |
} | |
-(void) viewDidDisappear:(BOOL)animated { | |
[super viewDidDisappear:animated]; | |
// It is recommended to not set ad delegate to nil or remove ad in the viewWillDisappear or | |
// viewDidDisappear method of the presenting view controller that is passed into | |
// fetchAndDisplayAdForSpace: and displayAdForSpace:onView:viewControllerForPresentation routines | |
} | |
/** | |
* Invoke a takeover at a natural pause in your app. For example, when a | |
* level is completed, an article is read or a button is pressed. We will | |
* mock the display of a takeover when a button is pressed. | |
*/ | |
-(IBAction) showFullScreenAdClickedButton:(id)sender { | |
// Check if ad is ready. If so, display the ad | |
if ([FlurryAds adReadyForSpace:adSpaceName]) { | |
[FlurryAds displayAdForSpace:adSpaceName onView:self.view viewControllerForPresentation:self]; | |
} else { | |
// Fetch an ad | |
[FlurryAds fetchAdForSpace:adSpaceName frame:self.view.frame size:FULLSCREEN]; | |
} | |
} | |
/* | |
* It is recommended to pause app activities when an interstitial is shown. | |
* Listen to should display delegate. | |
*/ | |
- (BOOL) spaceShouldDisplay:(NSString*)adSpace interstitial:(BOOL) | |
interstitial { | |
if (interstitial) { | |
// Pause app state here | |
} | |
// Continue ad display | |
return YES; | |
} | |
/* | |
* Resume app state when the interstitial is dismissed. | |
*/ | |
- (void)spaceDidDismiss:(NSString *)adSpace interstitial:(BOOL)interstitial { | |
if (interstitial) { | |
// Resume app state here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment