Reputation: 8236
I've set up Flurry ads in my app and most of the time, they work great. My game has several minigames, and at the end of each minigame, I show an ad.
However, occasionally the ad does not appear, leaving the user hanging on the game's end screen. I can't figure out a use case whereby this happens every time, rather it seems to occur randomly.
Once the ad has failed to appear, double tapping the home button (i.e. bringing up the app switcher menu) has the effect of dismissing the ad, and returning to my game's main screen. So it's as if the ad is there, but the user can't see it (or click x to dismiss it).
After this happens once, it happens every time, i.e. the app doesn't return to a state where ads work, unless I reboot the app completely (double tapping the home button etc).
I get many reports from my users of the app 'crashing' after every minigame, whereas what is actually happening is that the ad is failing to appear.
Below is my code to initialise and display the ads. The method [showFullScreenAd] is called successfully each time, and I have output statements from the delegates methods to confirm that ads have been successfully retrieved.
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
#ifdef ADVERTISING
if (![[NSUserDefaults standardUserDefaults] boolForKey:kIsProUpgradePurchased]) {
DLog(@"Fetching ads for hook %@", kAdHookInterstitial);
[FlurryAds fetchAdForSpace:kAdHookInterstitial
frame:self.view.frame
size:FULLSCREEN];
[FlurryAds setAdDelegate:self];
}
#endif
}
-(void) viewWillDisappear:(BOOL)animated {
#ifdef ADVERTISING
DLog(@"REMOVING ADS FROM SPACE: %@", kAdHookInterstitial);
if (![[NSUserDefaults standardUserDefaults] boolForKey:kIsProUpgradePurchased]) {
[FlurryAds removeAdFromSpace:kAdHookInterstitial];
[FlurryAds setAdDelegate:nil];
}
#endif
- (void)showFullScreenAd {
#ifdef ADVERTISING
if (![[NSUserDefaults standardUserDefaults] boolForKey:kIsProUpgradePurchased]) {
if ([FlurryAds adReadyForSpace:kAdHookInterstitial]) {
[FlurryAds displayAdForSpace:kAdHookInterstitial
onView:self.view];
}
else {
[self.navigationController popToRootViewControllerAnimated:YES];
}
}
#else
[self.navigationController popToRootViewControllerAnimated:YES];
#endif
}
Upvotes: 2
Views: 1117
Reputation: 56
You want to set the ad delegate before you initiate any ad activity. Otherwise, it's possible the SDK, which might otherwise forward a useful (fail) message to your delegate, will be unable to do so.
Where/how is showFullScreenAd
called? The method seems reasonable in that if an ad is not available, the controller is popped (presuming your root view controller is where you want to be in that case).
You can also implement FlurryAdDelegate
methods to alert you when the ad has successfully been fetched, and use that in your display functionality.
Since a fetch to the ad server could fail, it's often prudent to implement the FlurryAdDelegate#sapceDidFailToReceiveAd:error:
method. Depending on how you want to use ads in your integration, you might want to attempt another network request here.
http://support.flurry.com/index.php?title=Publisher/Code/Doc
Upvotes: 1